我正在尝试创建一个使用Modernizr.js来检测Mutation Observers的测试。在现代程序文档中,there's a section for testing DOM elements被称为前缀。我试着这样做:
Modernizr.load({
test: Modernizr.prefixed('MutationObserver', window),
yep: ['/js/polyfill_yep.js'],
nope: ['/js/polyfill_nope.js']
});但显然,这是行不通的。我得到了一个TypeError: f.bind is not a function,我非常确定前缀字符串不是MutationObserver,但我不知道它可能是什么,或者我是否正确地编写了测试。有什么想法吗?
发布于 2012-11-09 07:11:01
这就是胜利!
Modernizr.load({
test: MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserver,
yep: '/js/mutations.js',
nope: '/js/mutation_fallback.js'
});https://stackoverflow.com/questions/13297380
复制相似问题