You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
784 B
JavaScript
31 lines
784 B
JavaScript
import {CONTENT, PRIVATE} from '../shared/symbols.js';
|
|
|
|
import {registerHTMLClass} from '../shared/register-html-class.js';
|
|
|
|
import {HTMLElement} from './element.js';
|
|
|
|
const tagName = 'template';
|
|
|
|
/**
|
|
* @implements globalThis.HTMLTemplateElement
|
|
*/
|
|
class HTMLTemplateElement extends HTMLElement {
|
|
constructor(ownerDocument) {
|
|
super(ownerDocument, tagName);
|
|
const content = this.ownerDocument.createDocumentFragment();
|
|
(this[CONTENT] = content)[PRIVATE] = this;
|
|
}
|
|
|
|
get content() {
|
|
if (this.hasChildNodes() && !this[CONTENT].hasChildNodes()) {
|
|
for (const node of this.childNodes)
|
|
this[CONTENT].appendChild(node.cloneNode(true));
|
|
}
|
|
return this[CONTENT];
|
|
}
|
|
}
|
|
|
|
registerHTMLClass(tagName, HTMLTemplateElement);
|
|
|
|
export {HTMLTemplateElement};
|