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.
This commit is contained in:
parent
7026543663
commit
8bb96db3a0
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user