-
-
Save kmmbvnr/25ac3487b16ce07df82b1eaab0e1bbf2 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> | |
<html lang="en"> | |
<head> | |
<script type="text/javascript"> | |
class MyElement extends HTMLElement { | |
connectedCallback() { | |
alert(this.children.length); | |
} | |
} | |
window.customElements.define('my-element', MyElement); | |
</script> | |
</head> | |
<body> | |
<my-element><p>test</p></my-element> | |
</body> | |
</html> |
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> | |
<html lang="en"> | |
<head> | |
<script type="text/javascript"> | |
class MyElement extends HTMLElement { | |
constructor() { | |
super(); // always call super() first in the constructor. | |
} | |
connectedCallback() { | |
alert(this.children.length); | |
} | |
} | |
window.onload = function() { | |
window.customElements.define('my-element', MyElement); | |
}; | |
</script> | |
</head> | |
<body> | |
<my-element><p>test</p></my-element> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment