Created
December 9, 2016 19:26
-
-
Save bicknellr/567661eff48bb130add3bb1be86e37e2 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
<html> | |
<head> | |
<script> | |
customElements.define("x-outer", class extends HTMLElement { | |
connectedCallback() { | |
this.children[0].setAttribute('a', 'foo'); | |
} | |
}); | |
customElements.define("x-inner", class extends HTMLElement { | |
static get observedAttributes() { | |
return ["a"]; | |
} | |
connectedCallback() { | |
this.removeAttribute('a'); | |
} | |
attributeChangedCallback(name, oldValue, newValue) { | |
console.log("<x-inner> attributeChangedCallback", | |
"(", "name:", name, ", old:", oldValue, ", new:", newValue, ")" | |
); | |
} | |
}); | |
window.addEventListener("load", function() { | |
var template = document.querySelector("template"); | |
document.body.appendChild(document.importNode(template.content, true)); | |
}); | |
</script> | |
</head> | |
<body> | |
<template> | |
<x-outer> | |
<x-inner></x-inner> | |
</x-outer> | |
</template> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment