From 8bb96db3a0eff104ff0517fa810f0110e54c581a Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Wed, 30 Jul 2014 23:05:09 +0200 Subject: [PATCH] Use CSS.supports instead of '..' in ....style document.documentElement.style is null in some XML documents. The previous snippet caused the following error: Uncaught TypeError: Cannot use 'in' operator to search for 'animation' in null To fix this bug, `'animation' in document.documentElement.style` has been replaced with `CSS.supports('animation', '9s')`. This method was introduced in Chromium 28, but it is not necessary to detect whether this method is supported because the required createShadowRoot method for embeds is not available in Chromium 32 and earlier. --- extensions/chromium/contentscript.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extensions/chromium/contentscript.js b/extensions/chromium/contentscript.js index 531e0f7c1..e17c15f08 100644 --- a/extensions/chromium/contentscript.js +++ b/extensions/chromium/contentscript.js @@ -15,7 +15,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. */ -/* globals chrome */ +/* globals chrome, CSS */ 'use strict'; @@ -45,7 +45,7 @@ if (typeof Element.prototype.createShadowRoot !== 'undefined') { // Only observe the document if we can make use of Shadow DOM. if (createShadowRoot) { - if ('animation' in document.documentElement.style) { + if (CSS.supports('animation', '0s')) { document.addEventListener('animationstart', onAnimationStart, true); } else { document.addEventListener('webkitAnimationStart', onAnimationStart, true);