diff options
| author | gdh1995 | 2018-10-28 11:45:14 +0800 |
|---|---|---|
| committer | gdh1995 | 2018-10-28 11:45:14 +0800 |
| commit | acf09d2285b47d5849b4315ac698182dad7e9c13 (patch) | |
| tree | b5353dbe5b82a31bb6da751ee85f06f9878ab11d | |
| parent | 7c77b9bef6720283b04f6253b5e3cec0c7612b15 (diff) | |
| download | vimium-acf09d2285b47d5849b4315ac698182dad7e9c13.tar.bz2 | |
use Shadow DOM v1 if it exists
Chrome 70 has deprecated Shadow DOM v0
and displayed a warning when it's used.
And accroding to https://www.chromestatus.com/features/4507242028072960,
Shadow DOM v0 will be removed since Chrome 73.
The support for Shadow DOM v1 has been there since Chrome 53 and
is enabled by default on Firefox 63,
so it's time to use it.
Old support is still needed because Vimium's min_chrome_version is 51.
| -rw-r--r-- | content_scripts/ui_component.coffee | 2 | ||||
| -rw-r--r-- | content_scripts/vimium_frontend.coffee | 5 |
2 files changed, 5 insertions, 2 deletions
diff --git a/content_scripts/ui_component.coffee b/content_scripts/ui_component.coffee index c71bfb35..f0815d08 100644 --- a/content_scripts/ui_component.coffee +++ b/content_scripts/ui_component.coffee @@ -27,7 +27,7 @@ class UIComponent seamless: "seamless" shadowWrapper = DomUtils.createElement "div" # PhantomJS doesn't support createShadowRoot, so guard against its non-existance. - @shadowDOM = shadowWrapper.createShadowRoot?() ? shadowWrapper + @shadowDOM = shadowWrapper.attachShadow?() ? shadowWrapper.createShadowRoot?() ? shadowWrapper @shadowDOM.appendChild styleSheet @shadowDOM.appendChild @iframeElement @toggleIframeElementClasses "vimiumUIComponentVisible", "vimiumUIComponentHidden" diff --git a/content_scripts/vimium_frontend.coffee b/content_scripts/vimium_frontend.coffee index ff27c8a4..2eb4a0cd 100644 --- a/content_scripts/vimium_frontend.coffee +++ b/content_scripts/vimium_frontend.coffee @@ -245,7 +245,10 @@ flashFrame = do -> # Create a shadow DOM wrapping the frame so the page's styles don't interfere with ours. highlightedFrameElement = DomUtils.createElement "div" # PhantomJS doesn't support createShadowRoot, so guard against its non-existance. - _shadowDOM = highlightedFrameElement.createShadowRoot?() ? highlightedFrameElement + # https://hacks.mozilla.org/2018/10/firefox-63-tricks-and-treats/ says + # Firefox 63 has enabled Shadow DOM v1 by default + _shadowDOM = highlightedFrameElement.attachShadow?() ? + highlightedFrameElement.createShadowRoot?() ? highlightedFrameElement # Inject stylesheet. _styleSheet = DomUtils.createElement "style" |
