Skip to content

Instantly share code, notes, and snippets.

@thomaswilburn
Last active August 23, 2016 16:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thomaswilburn/2accfecb76bb304e6802c65d1567b568 to your computer and use it in GitHub Desktop.
Save thomaswilburn/2accfecb76bb304e6802c65d1567b568 to your computer and use it in GitHub Desktop.
document-register-element v1 shim test
var F = function(self) {
//being called from the shim
if (self) {
HTMLElement.call(self);
return self;
}
//must be native, use Reflect.construct() to perform super()
//this code is untested, came from rniwa
return Reflect.construct(HTMLElement, [], F);
};
F.prototype = Object.create(HTMLElement.prototype);
F.prototype.constructor = HTMLElement;
F.prototype.testMethod = function() {
console.log("hello world");
}
console.log(F);
//this works fine
customElements.define("st-tag", F);
//this currently crashes in Chrome Beta
//I don't think HTMLElement itself is being patched correctly
var el = document.createElement("st-tag");
el.testMethod();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment