-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
13 lines (13 loc) · 764 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
if('name' in document.createElement('slot') && 'attachShadow' in document.createElement('p')) {
let templateContent = document.querySelector('template').content;
let article = document.querySelector('article').cloneNode(true);
article.querySelectorAll('*[id]').forEach((ele)=>{ele.removeAttribute('id')})
article.attachShadow({ mode: 'closed' }).appendChild(templateContent.cloneNode(true));
document.querySelector('#toc').appendChild(article);
}
else{
let strong = document.createElement('strong');
strong.textContent = '⚠️ HTML Slot or Shadow DOM is not supported in your browser. Please try the demo in another browser.';
strong.style['color'] = 'red';
document.body.insertBefore(strong, document.querySelector('h1'))
}