diff options
| author | Stephen Blott | 2017-02-11 07:27:55 +0000 | 
|---|---|---|
| committer | GitHub | 2017-02-11 07:27:55 +0000 | 
| commit | 771b0abc9d60a31d29cb59de6edfe529a5e3005c (patch) | |
| tree | 4f462e37944285c1d70061b84836f15203a37875 | |
| parent | b12ed93d0b96df90511d3331e8a5f54e7b1b7da4 (diff) | |
| parent | 97586506fb861c9ca0af1e7fd4941ed0ec5b1b9b (diff) | |
| download | vimium-771b0abc9d60a31d29cb59de6edfe529a5e3005c.tar.bz2 | |
Merge pull request #2426 from mrmr1993/no-depreciated-apis
Replace depreciated APIs
| -rw-r--r-- | background_scripts/main.coffee | 12 | ||||
| -rw-r--r-- | background_scripts/marks.coffee | 2 | ||||
| -rw-r--r-- | content_scripts/mode.coffee | 2 | ||||
| -rw-r--r-- | content_scripts/mode_insert.coffee | 4 | ||||
| -rw-r--r-- | lib/dom_utils.coffee | 2 | ||||
| -rw-r--r-- | pages/options.coffee | 2 | ||||
| -rw-r--r-- | tests/unit_tests/test_chrome_stubs.coffee | 4 | 
7 files changed, 12 insertions, 16 deletions
| diff --git a/background_scripts/main.coffee b/background_scripts/main.coffee index 72f87a7e..70739eae 100644 --- a/background_scripts/main.coffee +++ b/background_scripts/main.coffee @@ -99,7 +99,7 @@ TabOperations =      tabConfig =        url: Utils.convertToUrl request.url        index: request.tab.index + 1 -      selected: true +      active: true        windowId: request.tab.windowId        openerTabId: request.tab.id      chrome.tabs.create tabConfig, callback @@ -127,11 +127,11 @@ toggleMuteTab = do ->  selectSpecificTab = (request) ->    chrome.tabs.get(request.id, (tab) ->      chrome.windows.update(tab.windowId, { focused: true }) -    chrome.tabs.update(request.id, { selected: true })) +    chrome.tabs.update(request.id, { active: true }))  moveTab = ({count, tab, registryEntry}) ->    count = -count if registryEntry.command == "moveTabLeft" -  chrome.tabs.getAllInWindow null, (tabs) -> +  chrome.tabs.query { currentWindow: true }, (tabs) ->      pinnedCount = (tabs.filter (tab) -> tab.pinned).length      minIndex = if tab.pinned then 0 else pinnedCount      maxIndex = (if tab.pinned then pinnedCount else tabs.length) - 1 @@ -226,7 +226,7 @@ removeTabsRelative = (direction, {tab: activeTab}) ->  # Selects a tab before or after the currently selected tab.  # - direction: "next", "previous", "first" or "last".  selectTab = (direction, {count, tab}) -> -  chrome.tabs.getAllInWindow null, (tabs) -> +  chrome.tabs.query { currentWindow: true }, (tabs) ->      if 1 < tabs.length        toSelect =          switch direction @@ -238,7 +238,7 @@ selectTab = (direction, {count, tab}) ->              Math.min tabs.length - 1, count - 1            when "last"              Math.max 0, tabs.length - count -      chrome.tabs.update tabs[toSelect].id, selected: true +      chrome.tabs.update tabs[toSelect].id, active: true  chrome.tabs.onUpdated.addListener (tabId, changeInfo, tab) ->    return unless changeInfo.status == "loading" # Only do this once per URL change. @@ -467,7 +467,7 @@ do showUpgradeMessage = ->              Settings.set "previousVersion", currentVersion              chrome.notifications.onClicked.addListener (id) ->                if id == notificationId -                chrome.tabs.getSelected null, (tab) -> +                chrome.tabs.query { active: true, currentWindow: true }, ([tab]) ->                    TabOperations.openUrlInNewTab {tab, tabId: tab.id, url: "https://github.com/philc/vimium#release-notes"}        else          # We need to wait for the user to accept the "notifications" permission. diff --git a/background_scripts/marks.coffee b/background_scripts/marks.coffee index dbc14671..33c467a7 100644 --- a/background_scripts/marks.coffee +++ b/background_scripts/marks.coffee @@ -57,7 +57,7 @@ Marks =    # Focus an existing tab and scroll to the given position within it.    gotoPositionInTab: ({ tabId, scrollX, scrollY, markName }) -> -    chrome.tabs.update tabId, {selected: true}, -> +    chrome.tabs.update tabId, { active: true }, ->        chrome.tabs.sendMessage tabId, {name: "setScrollPosition", scrollX, scrollY}    # The tab we're trying to find no longer exists.  We either find another tab with a matching URL and use it, diff --git a/content_scripts/mode.coffee b/content_scripts/mode.coffee index c1dea59a..2d8cc9cc 100644 --- a/content_scripts/mode.coffee +++ b/content_scripts/mode.coffee @@ -81,7 +81,7 @@ class Mode          _name: "mode-#{@id}/exitOnEscape"          "keydown": (event) =>            return @continueBubbling unless KeyboardUtils.isEscape event -          @exit event, event.srcElement +          @exit event, event.target            DomUtils.suppressKeyupAfterEscape handlerStack      # If @options.exitOnBlur is truthy, then it should be an element.  The mode will exit when that element diff --git a/content_scripts/mode_insert.coffee b/content_scripts/mode_insert.coffee index d5d98297..239a4bcc 100644 --- a/content_scripts/mode_insert.coffee +++ b/content_scripts/mode_insert.coffee @@ -17,14 +17,14 @@ class InsertMode extends Mode          return @suppressEvent        return @passEventToPage unless event.type == 'keydown' and KeyboardUtils.isEscape event -      target = event.srcElement +      target = event.target        if target and DomUtils.isFocusable target          # Remove the focus, so the user can't just get back into insert mode by typing in the same input box.          target.blur()        else if target?.shadowRoot and @insertModeLock          # An editable element in a shadow DOM is focused; blur it.          @insertModeLock.blur() -      @exit event, event.srcElement +      @exit event, event.target        DomUtils.suppressKeyupAfterEscape handlerStack      defaults = diff --git a/lib/dom_utils.coffee b/lib/dom_utils.coffee index fad5ffbf..500332e0 100644 --- a/lib/dom_utils.coffee +++ b/lib/dom_utils.coffee @@ -342,7 +342,7 @@ DomUtils =    # If the element is rendered in a shadow DOM via a <content> element, the <content> element will be    # returned, so the shadow DOM is traversed rather than passed over.    getContainingElement: (element) -> -    element.getDestinationInsertionPoints()[0] or element.parentElement +    element.getDestinationInsertionPoints?()[0] or element.parentElement    # This tests whether a window is too small to be useful.    windowIsTooSmall: -> diff --git a/pages/options.coffee b/pages/options.coffee index 0a71611a..8683b7ed 100644 --- a/pages/options.coffee +++ b/pages/options.coffee @@ -265,7 +265,7 @@ initOptionsPage = ->    maintainLinkHintsView()  initPopupPage = -> -  chrome.tabs.getSelected null, (tab) -> +  chrome.tabs.query { active: true, currentWindow: true }, ([tab]) ->      exclusions = null      document.getElementById("optionsLink").setAttribute "href", chrome.runtime.getURL("pages/options.html") diff --git a/tests/unit_tests/test_chrome_stubs.coffee b/tests/unit_tests/test_chrome_stubs.coffee index bea13df3..53ca805d 100644 --- a/tests/unit_tests/test_chrome_stubs.coffee +++ b/tests/unit_tests/test_chrome_stubs.coffee @@ -41,8 +41,6 @@ exports.chrome =      getViews: -> []    tabs: -    onSelectionChanged: -      addListener: () -> true      onUpdated:        addListener: () -> true      onAttached: @@ -51,8 +49,6 @@ exports.chrome =        addListener: () -> true      onRemoved:        addListener: () -> true -    onActiveChanged: -      addListener: () -> true      onActivated:        addListener: () -> true      onReplaced: | 
