- Delete old Vite+Svelte frontend - Initialize new SvelteKit project with TypeScript - Configure Tailwind CSS v4 + DaisyUI - Implement JWT authentication with auto-refresh - Create login page with form validation (Zod) - Add protected route guards - Update Docker configuration for single-stage build - Add E2E tests with Playwright (6/11 passing) - Fix Svelte 5 reactivity with $state() runes Known issues: - 5 E2E tests failing (timing/async issues) - Token refresh implementation needs debugging - Validation error display timing
111 lines
3.3 KiB
JavaScript
111 lines
3.3 KiB
JavaScript
import HTMLElement from '../html-element/HTMLElement.js';
|
|
import * as PropertySymbol from '../../PropertySymbol.js';
|
|
import HTMLSerializer from '../../html-serializer/HTMLSerializer.js';
|
|
import HTMLParser from '../../html-parser/HTMLParser.js';
|
|
/**
|
|
* HTML Template Element.
|
|
*
|
|
* Reference:
|
|
* https://developer.mozilla.org/en-US/docs/Web/API/HTMLTemplateElement.
|
|
*/
|
|
export default class HTMLTemplateElement extends HTMLElement {
|
|
// Internal properties
|
|
[PropertySymbol.content] = this[PropertySymbol.ownerDocument].createDocumentFragment();
|
|
/**
|
|
* Returns content.
|
|
*
|
|
* @returns Content.
|
|
*/
|
|
get content() {
|
|
return this[PropertySymbol.content];
|
|
}
|
|
/**
|
|
* @override
|
|
*/
|
|
get innerHTML() {
|
|
return this.getHTML();
|
|
}
|
|
/**
|
|
* @override
|
|
*/
|
|
set innerHTML(html) {
|
|
const content = this[PropertySymbol.content];
|
|
const childNodes = content[PropertySymbol.nodeArray];
|
|
while (childNodes.length) {
|
|
content.removeChild(childNodes[0]);
|
|
}
|
|
new HTMLParser(this[PropertySymbol.window]).parse(html, this[PropertySymbol.content]);
|
|
}
|
|
/**
|
|
* @override
|
|
*/
|
|
get firstChild() {
|
|
return this[PropertySymbol.content].firstChild;
|
|
}
|
|
/**
|
|
* @override
|
|
*/
|
|
get lastChild() {
|
|
return this[PropertySymbol.content].lastChild;
|
|
}
|
|
/**
|
|
* @deprecated
|
|
* @override
|
|
*/
|
|
getInnerHTML(_options) {
|
|
const serializer = new HTMLSerializer();
|
|
// Options should be ignored as shadow roots should not be serialized for HTMLTemplateElement.
|
|
const content = this[PropertySymbol.content];
|
|
let html = '';
|
|
for (const node of content[PropertySymbol.nodeArray]) {
|
|
html += serializer.serializeToString(node);
|
|
}
|
|
return html;
|
|
}
|
|
/**
|
|
* @override
|
|
*/
|
|
getHTML(_options) {
|
|
const serializer = new HTMLSerializer();
|
|
// Options should be ignored as shadow roots should not be serialized for HTMLTemplateElement.
|
|
const content = this[PropertySymbol.content];
|
|
let html = '';
|
|
for (const node of content[PropertySymbol.nodeArray]) {
|
|
html += serializer.serializeToString(node);
|
|
}
|
|
return html;
|
|
}
|
|
/**
|
|
* @override
|
|
*/
|
|
[PropertySymbol.appendChild](node, disableValidations = false) {
|
|
return this[PropertySymbol.content][PropertySymbol.appendChild](node, disableValidations);
|
|
}
|
|
/**
|
|
* @override
|
|
*/
|
|
[PropertySymbol.removeChild](node) {
|
|
return this[PropertySymbol.content][PropertySymbol.removeChild](node);
|
|
}
|
|
/**
|
|
* @override
|
|
*/
|
|
[PropertySymbol.insertBefore](newNode, referenceNode, disableValidations = false) {
|
|
return this[PropertySymbol.content][PropertySymbol.insertBefore](newNode, referenceNode, disableValidations);
|
|
}
|
|
/**
|
|
* @override
|
|
*/
|
|
[PropertySymbol.replaceChild](newChild, oldChild) {
|
|
return this[PropertySymbol.content][PropertySymbol.replaceChild](newChild, oldChild);
|
|
}
|
|
/**
|
|
* @override
|
|
*/
|
|
[PropertySymbol.cloneNode](deep = false) {
|
|
const clone = super[PropertySymbol.cloneNode](deep);
|
|
clone[PropertySymbol.content] = this[PropertySymbol.content].cloneNode(deep);
|
|
return clone;
|
|
}
|
|
}
|
|
//# sourceMappingURL=HTMLTemplateElement.js.map
|