Created
March 1, 2014 07:59
-
-
Save kuwalab/9286766 to your computer and use it in GitHub Desktop.
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
<!DOCTYPE html lang="ja"> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>カスタム要素</title> | |
</head> | |
<body> | |
<x-foo></x-foo><br> | |
<x-foo></x-foo> | |
<script> | |
var XFooPrototype = Object.create(HTMLElement.prototype); | |
XFooPrototype.createdCallback = function() { | |
this.innerHTML = '<span style="font-weight: bold; color: red;">あいうえお</span>'; | |
}; | |
XFooPrototype.foo = function() { | |
console.log('foo() called'); | |
}; | |
var XFoo = document.registerElement('x-foo', { | |
prototype: XFooPrototype | |
}); | |
</script> | |
</body> | |
</html> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment