Skip to content

Commit 771b0ab

Browse files
Merge pull request philc#2426 from mrmr1993/no-depreciated-apis
Replace depreciated APIs
2 parents b12ed93 + 9758650 commit 771b0ab

File tree

7 files changed

+12
-16
lines changed

7 files changed

+12
-16
lines changed

background_scripts/main.coffee

+6-6
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ TabOperations =
9999
tabConfig =
100100
url: Utils.convertToUrl request.url
101101
index: request.tab.index + 1
102-
selected: true
102+
active: true
103103
windowId: request.tab.windowId
104104
openerTabId: request.tab.id
105105
chrome.tabs.create tabConfig, callback
@@ -127,11 +127,11 @@ toggleMuteTab = do ->
127127
selectSpecificTab = (request) ->
128128
chrome.tabs.get(request.id, (tab) ->
129129
chrome.windows.update(tab.windowId, { focused: true })
130-
chrome.tabs.update(request.id, { selected: true }))
130+
chrome.tabs.update(request.id, { active: true }))
131131

132132
moveTab = ({count, tab, registryEntry}) ->
133133
count = -count if registryEntry.command == "moveTabLeft"
134-
chrome.tabs.getAllInWindow null, (tabs) ->
134+
chrome.tabs.query { currentWindow: true }, (tabs) ->
135135
pinnedCount = (tabs.filter (tab) -> tab.pinned).length
136136
minIndex = if tab.pinned then 0 else pinnedCount
137137
maxIndex = (if tab.pinned then pinnedCount else tabs.length) - 1
@@ -226,7 +226,7 @@ removeTabsRelative = (direction, {tab: activeTab}) ->
226226
# Selects a tab before or after the currently selected tab.
227227
# - direction: "next", "previous", "first" or "last".
228228
selectTab = (direction, {count, tab}) ->
229-
chrome.tabs.getAllInWindow null, (tabs) ->
229+
chrome.tabs.query { currentWindow: true }, (tabs) ->
230230
if 1 < tabs.length
231231
toSelect =
232232
switch direction
@@ -238,7 +238,7 @@ selectTab = (direction, {count, tab}) ->
238238
Math.min tabs.length - 1, count - 1
239239
when "last"
240240
Math.max 0, tabs.length - count
241-
chrome.tabs.update tabs[toSelect].id, selected: true
241+
chrome.tabs.update tabs[toSelect].id, active: true
242242

243243
chrome.tabs.onUpdated.addListener (tabId, changeInfo, tab) ->
244244
return unless changeInfo.status == "loading" # Only do this once per URL change.
@@ -467,7 +467,7 @@ do showUpgradeMessage = ->
467467
Settings.set "previousVersion", currentVersion
468468
chrome.notifications.onClicked.addListener (id) ->
469469
if id == notificationId
470-
chrome.tabs.getSelected null, (tab) ->
470+
chrome.tabs.query { active: true, currentWindow: true }, ([tab]) ->
471471
TabOperations.openUrlInNewTab {tab, tabId: tab.id, url: "https://github.com/philc/vimium#release-notes"}
472472
else
473473
# We need to wait for the user to accept the "notifications" permission.

background_scripts/marks.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ Marks =
5757

5858
# Focus an existing tab and scroll to the given position within it.
5959
gotoPositionInTab: ({ tabId, scrollX, scrollY, markName }) ->
60-
chrome.tabs.update tabId, {selected: true}, ->
60+
chrome.tabs.update tabId, { active: true }, ->
6161
chrome.tabs.sendMessage tabId, {name: "setScrollPosition", scrollX, scrollY}
6262

6363
# The tab we're trying to find no longer exists. We either find another tab with a matching URL and use it,

content_scripts/mode.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ class Mode
8181
_name: "mode-#{@id}/exitOnEscape"
8282
"keydown": (event) =>
8383
return @continueBubbling unless KeyboardUtils.isEscape event
84-
@exit event, event.srcElement
84+
@exit event, event.target
8585
DomUtils.suppressKeyupAfterEscape handlerStack
8686

8787
# If @options.exitOnBlur is truthy, then it should be an element. The mode will exit when that element

content_scripts/mode_insert.coffee

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,14 @@ class InsertMode extends Mode
1717
return @suppressEvent
1818

1919
return @passEventToPage unless event.type == 'keydown' and KeyboardUtils.isEscape event
20-
target = event.srcElement
20+
target = event.target
2121
if target and DomUtils.isFocusable target
2222
# Remove the focus, so the user can't just get back into insert mode by typing in the same input box.
2323
target.blur()
2424
else if target?.shadowRoot and @insertModeLock
2525
# An editable element in a shadow DOM is focused; blur it.
2626
@insertModeLock.blur()
27-
@exit event, event.srcElement
27+
@exit event, event.target
2828
DomUtils.suppressKeyupAfterEscape handlerStack
2929

3030
defaults =

lib/dom_utils.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,7 @@ DomUtils =
342342
# If the element is rendered in a shadow DOM via a <content> element, the <content> element will be
343343
# returned, so the shadow DOM is traversed rather than passed over.
344344
getContainingElement: (element) ->
345-
element.getDestinationInsertionPoints()[0] or element.parentElement
345+
element.getDestinationInsertionPoints?()[0] or element.parentElement
346346

347347
# This tests whether a window is too small to be useful.
348348
windowIsTooSmall: ->

pages/options.coffee

+1-1
Original file line numberDiff line numberDiff line change
@@ -265,7 +265,7 @@ initOptionsPage = ->
265265
maintainLinkHintsView()
266266

267267
initPopupPage = ->
268-
chrome.tabs.getSelected null, (tab) ->
268+
chrome.tabs.query { active: true, currentWindow: true }, ([tab]) ->
269269
exclusions = null
270270
document.getElementById("optionsLink").setAttribute "href", chrome.runtime.getURL("pages/options.html")
271271

tests/unit_tests/test_chrome_stubs.coffee

-4
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,6 @@ exports.chrome =
4141
getViews: -> []
4242

4343
tabs:
44-
onSelectionChanged:
45-
addListener: () -> true
4644
onUpdated:
4745
addListener: () -> true
4846
onAttached:
@@ -51,8 +49,6 @@ exports.chrome =
5149
addListener: () -> true
5250
onRemoved:
5351
addListener: () -> true
54-
onActiveChanged:
55-
addListener: () -> true
5652
onActivated:
5753
addListener: () -> true
5854
onReplaced:

0 commit comments

Comments
 (0)