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.

32 lines
834 B
JavaScript

'use strict';
const {CONTENT, PRIVATE} = require('../shared/symbols.js');
const {registerHTMLClass} = require('../shared/register-html-class.js');
const {HTMLElement} = require('./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);
exports.HTMLTemplateElement = HTMLTemplateElement;