Skip to content

Instantly share code, notes, and snippets.

@riodw
Last active April 25, 2017 15:15
Show Gist options
  • Save riodw/4fd7595d6b775752193497908ca16021 to your computer and use it in GitHub Desktop.
Save riodw/4fd7595d6b775752193497908ca16021 to your computer and use it in GitHub Desktop.
<!-- Rio Weber
Create Custom HTML Element -->
<html>
<head>
<title>Make Custom HTML Element</title>
</head>
<body>
<hello-element></hello-element>
<script>
var proto = Object.create(HTMLElement.prototype);
proto.createdCallback = function() {
this.textContent = 'Hello World!';
}
proto.addMoreText = function(s) {
this.textContent = this.textContent + s;
}
document.registerElement('hello-element', {
prototype: proto
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment