I hereby claim:
- I am dmies on github.
- I am danielmies (https://keybase.io/danielmies) on keybase.
- I have a public key ASAXEdMDE25Lq120iWi2LaApLLeC_BfJCU0-tIzcm0PsJwo
To claim this, I am signing this object:
if ("import" in document.createElement("link")) { | |
// magic... | |
} |
if ("import" in document.createElement("link")) { | |
const link = document.querySelector('link[rel="import"]'); // (1) | |
const content = link.import; | |
const element = content.querySelector("#webcomponents"); // (2) | |
document.body.appendChild(element.cloneNode(true)); // (3) | |
} |
if (document.head.createShadowRoot || document.head.attachShadow) { | |
// magic happens here | |
} |
<div id=”webcomponents”></div> | |
<p>normal paragraph</p> |
if (document.head.createShadowRoot || document.head.attachShadow) { | |
const shadow = document.querySelector("#webcomponents").attachShadow({ | |
// (1) | |
mode: "open"(2) | |
}); | |
shadow.innerHTML = "<p>HTML Template</p>"; // (2) | |
shadow.innerHTML += "<p>HTML Import</p>"; | |
shadow.innerHTML += "<p>Shadow DOM</p>"; | |
shadow.innerHTML += "<p>Custom Elements</p>"; |
<web-components></web-components> |
if ("customElements" in window) { | |
// magic happens here | |
} |
if ("customElements" in window) { | |
class WebComponents extends HTMLElement { | |
// (1) | |
constructor() { | |
super(); | |
this.innerHTML = | |
//(2) | |
`<ul> | |
<li>HTML Template</li> | |
<li>HTML Import</li> |
let tmpl = document.createElement("template"); // (1) | |
tmpl.innerHTML = ` | |
<ul id="webcomponents"> | |
<li>HTML Template</li> | |
<li>HTML Import</li> | |
<li>Shadow DOM</li> | |
<li>Custom Elements</li> | |
</ul>`; | |
class WebComponents extends HTMLElement { |
I hereby claim:
To claim this, I am signing this object: