Created
October 16, 2018 06:21
-
-
Save dzenzes/10d9c32cf144f3d8b32e29657e9de3b1 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
if ("content" in document.createElement("template")) { | |
const features = [ | |
"HTML Template", | |
"HTML Import", | |
"Shadow DOM", | |
"Custom Elements" | |
]; | |
const template = document.querySelector("#feature"); // (1) | |
let listItem = template.content.querySelectorAll("li"); // (2) | |
let list = document.getElementById("webcomponents"); // (3) | |
features.forEach(feature => { | |
listItem[0].textContent = feature; // (4) | |
const clone = document.importNode(template.content, true); // (5) | |
list.appendChild(clone); // (6) | |
}); | |
} else { | |
document.body.appendChild( | |
document.createTextNode("HTML templates are not supported") | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment