Created
June 1, 2012 22:16
-
-
Save arv/2855456 to your computer and use it in GitHub Desktop.
Custom Elements
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// And in browsers that support __proto__: | |
document.register('x-foo', { | |
extends: 'p', | |
prototype: { | |
__proto__: HTMLParagraphElement.prototype, | |
get foo() { return 'foo'; } | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var p = Object.create(HTMLParagraphElement.prototype); | |
p.hello = function() { alert('world'); }; | |
document.register('x-foo', { | |
extends: 'p', | |
prototype: p | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// And in browsers that support __proto__: | |
document.register('x-foo', { | |
extends: 'p', | |
prototype: { | |
__proto__: HTMLParagraphElement.prototype, | |
get foo() { return 'foo'; } | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.register('x-foo', { | |
extends: 'p', | |
prototype: Object.create(HTMLParagraphElement.prototype, { | |
foo: { | |
get: function() { return foo; }, | |
enumerable: true, | |
configurable: true | |
} | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment