[英]How to test for DOM4 Mutation Observers with Modernizr.js?
I'm trying to create a test to detect for Mutation Observers using Modernizr.js. 我正在尝试使用Modernizr.js创建一个检测Mutation Observers的测试。 On the Modernizer Documentation, there's a section for testing DOM elements known as prefixes.
在Modernizer文档中, 有一个用于测试称为前缀的DOM元素的部分 。 I tried that using:
我尝试使用:
Modernizr.load({
test: Modernizr.prefixed('MutationObserver', window),
yep: ['/js/polyfill_yep.js'],
nope: ['/js/polyfill_nope.js']
});
But obviously, that isn't working. 但显然,这是行不通的。 I'm getting a
TypeError: f.bind is not a function
I'm fairly certain the prefixed string isn't MutationObserver, but I don't know what it could be, or even if I'm writing the test correctly. 我得到一个
TypeError: f.bind is not a function
我很确定前缀字符串不是MutationObserver,但我不知道它可能是什么,或者即使我正确地编写了测试。 Any ideas? 有任何想法吗?
Here's a win! 这是一场胜利!
Modernizr.load({
test: MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver,
yep: '/js/mutations.js',
nope: '/js/mutation_fallback.js'
});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.