Javascript 在phantomjs中工作的document.register没有多边形填充
假设我正在编写以下web组件或自定义元素: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
<!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();
});