Javascript Polymer/platform.js polyfill addEventListener在iOS设备中为空
在Polymer的演示页面上,一切正常,在我的页面上,一切都坏了 在这条线上窒息:Javascript Polymer/platform.js polyfill addEventListener在iOS设备中为空,javascript,ios,iphone,polymer,polyfills,Javascript,Ios,Iphone,Polymer,Polyfills,在Polymer的演示页面上,一切正常,在我的页面上,一切都坏了 在这条线上窒息: var isSafari = nav.userAgent.match('Safari') && !nav.userAgent.match('Chrome'); if (isSafari) { // v -- choking here -- v document.body.addEventListener('touchstart', func
var isSafari = nav.userAgent.match('Safari') && !nav.userAgent.match('Chrome');
if (isSafari) {
// v -- choking here -- v
document.body.addEventListener('touchstart', function(){});
}
}
}
dispatcher.register(document, true);
})(window.PolymerGestures);
我在控制台中遇到以下错误:
Uncaught TypeError: Cannot read property 'addEventListener' of null
看起来body
为空,调试器确认
这里是我包含platform.js的地方:
<!DOCTYPE html>
<html class="no-js">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>{{ page.title }}</title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="apple-mobile-web-app-capable" content="yes">
<script src="/components/platform/platform.js"></script>
<link rel="import" href="/components/paper-tabs/paper-tabs.html">
{{page.title}}
这是master中修复的错误:
请在github上提交任何其他类似的bug。值得一提的是,它在Firefox和Chrome中工作。谢谢,伙计,我不确定这是不是一个真正的bug。大家都知道我在这件事上太先发制人了。