Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/436.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 在phantomjs中工作的document.register没有多边形填充_Javascript_Polyfills_Web Component - Fatal编程技术网

Javascript 在phantomjs中工作的document.register没有多边形填充

Javascript 在phantomjs中工作的document.register没有多边形填充,javascript,polyfills,web-component,Javascript,Polyfills,Web Component,假设我正在编写以下web组件或自定义元素: <!doctype html> <html> <head> <script src="js/MutationObserver.js"></script> <script src="js/CustomElements.js"></script> <script> var proto = Object.create(H

假设我正在编写以下web组件或自定义元素:

<!doctype html>

<html>
  <head>
    <script src="js/MutationObserver.js"></script>
    <script src="js/CustomElements.js"></script>

    <script>
      var proto = Object.create(HTMLElement.prototype);

      proto.createdCallback = function() { console.log('created');};
      proto.enteredViewCallback = function() {};

      document.register('x-foo', {prototype: proto});

      document.createElement('x-foo');
    </script>
  </head>

  <body>
  </body>
</html>
如果你想复制,这里是我的phantomjs脚本

var page = require('webpage').create();
page.open('http://localhost/~me/test.html', function() {
  phantom.exit();
});
我也试过其他类似的填充物


但实际上,它们都不起作用。有没有办法解决这个问题?

我也有同样的问题。使用此polyfill解决了此问题:


您需要使用document.registerement方法。

仅链接答案可能重复不是好主意。请在你的帖子中解释更多并解决这个问题。然后添加一些链接以了解更多信息。
var page = require('webpage').create();
page.open('http://localhost/~me/test.html', function() {
  phantom.exit();
});