Skip to content

Instantly share code, notes, and snippets.

@bicknellr
Created December 9, 2016 19:26
Show Gist options
  • Save bicknellr/567661eff48bb130add3bb1be86e37e2 to your computer and use it in GitHub Desktop.
Save bicknellr/567661eff48bb130add3bb1be86e37e2 to your computer and use it in GitHub Desktop.
<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