【问题标题】:Polymer/platform.js polyfill addEventListener null in iOS deviceiOS 设备中的 Polymer/platform.js polyfill addEventListener null
【发布时间】:2014-09-04 05:50:20
【问题描述】:

在 Polymer 的演示页面上,一切正常,在我的页面上,它坏了。

在这一行窒息:

      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">

【问题讨论】:

  • 值得一提,适用于 Firefox 和 Chrome。

标签: javascript ios iphone polymer polyfills


【解决方案1】:

这是 master 中修复的错误:https://github.com/Polymer/polymer-gestures/pull/47

请在 github 上提交任何其他类似的错误。

【讨论】:

  • 谢谢,我不确定这是不是一个真正的错误。众所周知,我对此过于先发制人。
猜你喜欢
  • 2015-07-24
  • 1970-01-01
  • 2015-11-03
  • 2017-11-29
  • 2017-03-06
  • 1970-01-01
  • 2019-10-23
  • 2016-10-14
  • 1970-01-01
相关资源
最近更新 更多