Created
March 27, 2018 20:54
-
-
Save jcgregorio/b2ef81944bdec8f617c1da87d406a2b8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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> | |
<head> | |
<title>select-sk demo</title> | |
<meta charset="utf-8" /> | |
<meta http-equiv="X-UA-Compatible" content="IE=egde,chrome=1"> | |
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | |
<script type="text/javascript" charset="utf-8"> | |
// This bit of script loads the custom elements v1 polyfill, but only if required. | |
if (!window.customElements) { | |
var newScript = document.createElement('script'); | |
newScript.src = "https://cdnjs.cloudflare.com/ajax/libs/custom-elements/1.0.8/custom-elements.min.js"; | |
document.write(newScript.outerHTML); | |
} | |
</script> | |
</head> | |
<body> | |
<div></div> | |
<script type="text/javascript" charset="utf-8"> | |
window.customElements.define('foo-x', class extends HTMLElement { | |
memberFunc() { | |
console.log('Inside memberFunc.'); | |
} | |
}); | |
window.customElements.whenDefined('foo-x').then(() => { | |
console.log('foo-x defined'); | |
document.querySelector('div').innerHTML = '<foo-x>hello world</foo-x>'; | |
document.querySelector('foo-x').memberFunc(); | |
}); | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment