feat: Reinitialize frontend with SvelteKit and TypeScript

- 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
This commit is contained in:
2026-02-17 16:19:59 -05:00
parent 54df6018f5
commit de2d83092e
28274 changed files with 3816354 additions and 90 deletions

View File

@@ -0,0 +1,6 @@
import CSSStyleDeclarationPropertyManager from '../../css/declaration/property-manager/CSSStyleDeclarationPropertyManager.js';
import ICachedResult from './ICachedResult.js';
export default interface ICachedComputedStyleResult extends ICachedResult {
result: WeakRef<CSSStyleDeclarationPropertyManager> | null;
}
//# sourceMappingURL=ICachedComputedStyleResult.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachedComputedStyleResult.d.ts","sourceRoot":"","sources":["../../../src/nodes/node/ICachedComputedStyleResult.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,MAAM,8EAA8E,CAAC;AAC9H,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAE/C,MAAM,CAAC,OAAO,WAAW,0BAA2B,SAAQ,aAAa;IACxE,MAAM,EAAE,OAAO,CAAC,kCAAkC,CAAC,GAAG,IAAI,CAAC;CAC3D"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ICachedComputedStyleResult.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachedComputedStyleResult.js","sourceRoot":"","sources":["../../../src/nodes/node/ICachedComputedStyleResult.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,6 @@
import Element from '../element/Element.js';
import ICachedResult from './ICachedResult.js';
export default interface ICachedElementByIdResult extends ICachedResult {
result: WeakRef<Element> | null;
}
//# sourceMappingURL=ICachedElementByIdResult.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachedElementByIdResult.d.ts","sourceRoot":"","sources":["../../../src/nodes/node/ICachedElementByIdResult.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAE/C,MAAM,CAAC,OAAO,WAAW,wBAAyB,SAAQ,aAAa;IACtE,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;CAChC"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ICachedElementByIdResult.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachedElementByIdResult.js","sourceRoot":"","sources":["../../../src/nodes/node/ICachedElementByIdResult.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,6 @@
import Element from '../element/Element.js';
import ICachedResult from './ICachedResult.js';
export default interface ICachedElementByTagNameResult extends ICachedResult {
result: WeakRef<Element> | null;
}
//# sourceMappingURL=ICachedElementByTagNameResult.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachedElementByTagNameResult.d.ts","sourceRoot":"","sources":["../../../src/nodes/node/ICachedElementByTagNameResult.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAE/C,MAAM,CAAC,OAAO,WAAW,6BAA8B,SAAQ,aAAa;IAC3E,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;CAChC"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ICachedElementByTagNameResult.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachedElementByTagNameResult.js","sourceRoot":"","sources":["../../../src/nodes/node/ICachedElementByTagNameResult.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,6 @@
import Element from '../element/Element.js';
import ICachedResult from './ICachedResult.js';
export default interface ICachedElementsByTagNameResult extends ICachedResult {
result: WeakRef<Element[]> | null;
}
//# sourceMappingURL=ICachedElementsByTagNameResult.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachedElementsByTagNameResult.d.ts","sourceRoot":"","sources":["../../../src/nodes/node/ICachedElementsByTagNameResult.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAE/C,MAAM,CAAC,OAAO,WAAW,8BAA+B,SAAQ,aAAa;IAC5E,MAAM,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC;CAClC"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ICachedElementsByTagNameResult.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachedElementsByTagNameResult.js","sourceRoot":"","sources":["../../../src/nodes/node/ICachedElementsByTagNameResult.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,8 @@
import ISelectorMatch from '../../query-selector/ISelectorMatch.js';
import ICachedResult from './ICachedResult.js';
export default interface ICachedMatchesResult extends ICachedResult {
result: {
match: ISelectorMatch | null;
} | null;
}
//# sourceMappingURL=ICachedMatchesResult.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachedMatchesResult.d.ts","sourceRoot":"","sources":["../../../src/nodes/node/ICachedMatchesResult.ts"],"names":[],"mappings":"AAAA,OAAO,cAAc,MAAM,wCAAwC,CAAC;AACpE,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAE/C,MAAM,CAAC,OAAO,WAAW,oBAAqB,SAAQ,aAAa;IAClE,MAAM,EAAE;QAAE,KAAK,EAAE,cAAc,GAAG,IAAI,CAAA;KAAE,GAAG,IAAI,CAAC;CAChD"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ICachedMatchesResult.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachedMatchesResult.js","sourceRoot":"","sources":["../../../src/nodes/node/ICachedMatchesResult.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,7 @@
import Element from '../element/Element.js';
import ICachedResult from './ICachedResult.js';
import NodeList from './NodeList.js';
export default interface ICachedQuerySelectorAllResult extends ICachedResult {
result: WeakRef<NodeList<Element>> | null;
}
//# sourceMappingURL=ICachedQuerySelectorAllResult.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachedQuerySelectorAllResult.d.ts","sourceRoot":"","sources":["../../../src/nodes/node/ICachedQuerySelectorAllResult.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAC/C,OAAO,QAAQ,MAAM,eAAe,CAAC;AAErC,MAAM,CAAC,OAAO,WAAW,6BAA8B,SAAQ,aAAa;IAC3E,MAAM,EAAE,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;CAC1C"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ICachedQuerySelectorAllResult.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachedQuerySelectorAllResult.js","sourceRoot":"","sources":["../../../src/nodes/node/ICachedQuerySelectorAllResult.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,6 @@
import Element from '../element/Element.js';
import ICachedResult from './ICachedResult.js';
export default interface ICachedQuerySelectorResult extends ICachedResult {
result: WeakRef<Element> | null;
}
//# sourceMappingURL=ICachedQuerySelectorResult.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachedQuerySelectorResult.d.ts","sourceRoot":"","sources":["../../../src/nodes/node/ICachedQuerySelectorResult.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAC5C,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAE/C,MAAM,CAAC,OAAO,WAAW,0BAA2B,SAAQ,aAAa;IACxE,MAAM,EAAE,OAAO,CAAC,OAAO,CAAC,GAAG,IAAI,CAAC;CAChC"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ICachedQuerySelectorResult.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachedQuerySelectorResult.js","sourceRoot":"","sources":["../../../src/nodes/node/ICachedQuerySelectorResult.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,4 @@
export default interface ICachedResult {
result: any | null;
}
//# sourceMappingURL=ICachedResult.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachedResult.d.ts","sourceRoot":"","sources":["../../../src/nodes/node/ICachedResult.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,WAAW,aAAa;IACrC,MAAM,EAAE,GAAG,GAAG,IAAI,CAAC;CACnB"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ICachedResult.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachedResult.js","sourceRoot":"","sources":["../../../src/nodes/node/ICachedResult.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,6 @@
import CSSStyleDeclarationPropertyManager from '../../css/declaration/property-manager/CSSStyleDeclarationPropertyManager.js';
import ICachedResult from './ICachedResult.js';
export default interface ICachedStyleResult extends ICachedResult {
result: WeakRef<CSSStyleDeclarationPropertyManager> | null;
}
//# sourceMappingURL=ICachedStyleResult.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachedStyleResult.d.ts","sourceRoot":"","sources":["../../../src/nodes/node/ICachedStyleResult.ts"],"names":[],"mappings":"AAAA,OAAO,kCAAkC,MAAM,8EAA8E,CAAC;AAC9H,OAAO,aAAa,MAAM,oBAAoB,CAAC;AAE/C,MAAM,CAAC,OAAO,WAAW,kBAAmB,SAAQ,aAAa;IAChE,MAAM,EAAE,OAAO,CAAC,kCAAkC,CAAC,GAAG,IAAI,CAAC;CAC3D"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=ICachedStyleResult.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"ICachedStyleResult.js","sourceRoot":"","sources":["../../../src/nodes/node/ICachedStyleResult.ts"],"names":[],"mappings":""}

View File

@@ -0,0 +1,367 @@
import EventTarget from '../../event/EventTarget.js';
import * as PropertySymbol from '../../PropertySymbol.js';
import Document from '../document/Document.js';
import Element from '../element/Element.js';
import NodeTypeEnum from './NodeTypeEnum.js';
import NodeDocumentPositionEnum from './NodeDocumentPositionEnum.js';
import NodeList from './NodeList.js';
import MutationRecord from '../../mutation-observer/MutationRecord.js';
import IMutationListener from '../../mutation-observer/IMutationListener.js';
import ICachedQuerySelectorAllResult from './ICachedQuerySelectorAllResult.js';
import ICachedQuerySelectorResult from './ICachedQuerySelectorResult.js';
import ICachedMatchesResult from './ICachedMatchesResult.js';
import ICachedElementsByTagNameResult from './ICachedElementsByTagNameResult.js';
import ICachedElementByTagNameResult from './ICachedElementByTagNameResult.js';
import ICachedComputedStyleResult from './ICachedComputedStyleResult.js';
import ICachedResult from './ICachedResult.js';
import ICachedElementByIdResult from './ICachedElementByIdResult.js';
import HTMLStyleElement from '../html-style-element/HTMLStyleElement.js';
import HTMLFormElement from '../html-form-element/HTMLFormElement.js';
import HTMLSelectElement from '../html-select-element/HTMLSelectElement.js';
import HTMLTextAreaElement from '../html-text-area-element/HTMLTextAreaElement.js';
import HTMLSlotElement from '../html-slot-element/HTMLSlotElement.js';
import SVGStyleElement from '../svg-style-element/SVGStyleElement.js';
/**
* Node.
*/
export default class Node extends EventTarget {
[PropertySymbol.ownerDocument]: Document;
static readonly ELEMENT_NODE = NodeTypeEnum.elementNode;
static readonly ATTRIBUTE_NODE = NodeTypeEnum.attributeNode;
static readonly TEXT_NODE = NodeTypeEnum.textNode;
static readonly CDATA_SECTION_NODE = NodeTypeEnum.cdataSectionNode;
static readonly COMMENT_NODE = NodeTypeEnum.commentNode;
static readonly DOCUMENT_NODE = NodeTypeEnum.documentNode;
static readonly DOCUMENT_TYPE_NODE = NodeTypeEnum.documentTypeNode;
static readonly DOCUMENT_FRAGMENT_NODE = NodeTypeEnum.documentFragmentNode;
static readonly PROCESSING_INSTRUCTION_NODE = NodeTypeEnum.processingInstructionNode;
static readonly DOCUMENT_POSITION_CONTAINED_BY = NodeDocumentPositionEnum.containedBy;
static readonly DOCUMENT_POSITION_CONTAINS = NodeDocumentPositionEnum.contains;
static readonly DOCUMENT_POSITION_DISCONNECTED = NodeDocumentPositionEnum.disconnect;
static readonly DOCUMENT_POSITION_FOLLOWING = NodeDocumentPositionEnum.following;
static readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC = NodeDocumentPositionEnum.implementationSpecific;
static readonly DOCUMENT_POSITION_PRECEDING = NodeDocumentPositionEnum.preceding;
readonly ELEMENT_NODE: any;
readonly ATTRIBUTE_NODE: any;
readonly TEXT_NODE: any;
readonly CDATA_SECTION_NODE: any;
readonly COMMENT_NODE: any;
readonly DOCUMENT_NODE: any;
readonly DOCUMENT_TYPE_NODE: any;
readonly DOCUMENT_FRAGMENT_NODE: any;
readonly PROCESSING_INSTRUCTION_NODE: any;
readonly DOCUMENT_POSITION_CONTAINED_BY: any;
readonly DOCUMENT_POSITION_CONTAINS: any;
readonly DOCUMENT_POSITION_DISCONNECTED: any;
readonly DOCUMENT_POSITION_FOLLOWING: any;
readonly DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC: any;
readonly DOCUMENT_POSITION_PRECEDING: any;
[PropertySymbol.isConnected]: boolean;
[PropertySymbol.parentNode]: Node | null;
[PropertySymbol.nodeType]: NodeTypeEnum;
[PropertySymbol.rootNode]: Node;
[PropertySymbol.styleNode]: HTMLStyleElement | SVGStyleElement | null;
[PropertySymbol.textAreaNode]: HTMLTextAreaElement | null;
[PropertySymbol.formNode]: HTMLFormElement | null;
[PropertySymbol.selectNode]: HTMLSelectElement | null;
[PropertySymbol.mutationListeners]: IMutationListener[];
[PropertySymbol.nodeArray]: Node[];
[PropertySymbol.elementArray]: Element[];
[PropertySymbol.childNodes]: NodeList<Node> | null;
[PropertySymbol.assignedToSlot]: HTMLSlotElement | null;
[PropertySymbol.cache]: {
querySelector: Map<string, ICachedQuerySelectorResult>;
querySelectorAll: Map<string, ICachedQuerySelectorAllResult>;
matches: Map<string, ICachedMatchesResult>;
elementsByTagName: Map<string, ICachedElementsByTagNameResult>;
elementsByTagNameNS: Map<string, ICachedElementsByTagNameResult>;
elementByTagName: Map<string, ICachedElementByTagNameResult>;
elementById: Map<string, ICachedElementByIdResult>;
computedStyle: ICachedComputedStyleResult | null;
};
[PropertySymbol.affectsCache]: ICachedResult[];
/**
* Constructor.
*/
constructor();
/**
* Returns `Symbol.toStringTag`.
*
* @returns `Symbol.toStringTag`.
*/
get [Symbol.toStringTag](): string;
/**
* Returns connected state.
*
* @returns Connected state.
*/
get isConnected(): boolean;
/**
* Returns owner document.
*
* @returns Owner document.
*/
get ownerDocument(): Document;
/**
* Returns parent node.
*
* @returns Parent node.
*/
get parentNode(): Node | null;
/**
* Returns node type.
*
* @returns Node type.
*/
get nodeType(): number;
/**
* Get child nodes.
*
* @returns Child nodes list.
*/
get childNodes(): NodeList<Node>;
/**
* Get text value of children.
*
* @returns Text content.
*/
get textContent(): string;
/**
* Sets text content.
*
* @param _textContent Text content.
*/
set textContent(_textContent: string);
/**
* Node value.
*
* @returns Node value.
*/
get nodeValue(): string;
/**
* Sets node value.
*/
set nodeValue(_nodeValue: string);
/**
* Node name.
*
* @returns Node name.
*/
get nodeName(): string;
/**
* Previous sibling.
*
* @returns Node.
*/
get previousSibling(): Node;
/**
* Next sibling.
*
* @returns Node.
*/
get nextSibling(): Node;
/**
* First child.
*
* @returns Node.
*/
get firstChild(): Node;
/**
* Last child.
*
* @returns Node.
*/
get lastChild(): Node;
/**
* Returns parent element.
*
* @returns Element.
*/
get parentElement(): Element | null;
/**
* Returns base URI.
*
* @returns Base URI.
*/
get baseURI(): string;
/**
* Returns "true" if the node has child nodes.
*
* @returns "true" if the node has child nodes.
*/
hasChildNodes(): boolean;
/**
* Returns "true" if this node contains the other node.
*
* @param otherNode Node to test with.
* @returns "true" if this node contains the other node.
*/
contains(otherNode: Node): boolean;
/**
* Returns closest root node (Document or ShadowRoot).
*
* @param options Options.
* @param options.composed A Boolean that indicates whether the shadow root should be returned (false, the default), or a root node beyond shadow root (true).
* @returns Node.
*/
getRootNode(options?: {
composed: boolean;
}): Node;
/**
* Clones a node.
*
* @param [deep=false] "true" to clone deep.
* @returns Cloned node.
*/
cloneNode(deep?: boolean): Node;
/**
* Append a child node to childNodes.
*
* @param node Node to append.
* @returns Appended node.
*/
appendChild(node: Node): Node;
/**
* Remove Child element from childNodes array.
*
* @param node Node to remove.
* @returns Removed node.
*/
removeChild(node: Node): Node;
/**
* Inserts a node before another.
*
* @param newNode Node to insert.
* @param referenceNode Node to insert before.
* @returns Inserted node.
*/
insertBefore(newNode: Node, referenceNode: Node | null): Node;
/**
* Replaces a node with another.
*
* @param newChild New child.
* @param oldChild Old child.
* @returns Replaced node.
*/
replaceChild(newChild: Node, oldChild: Node): Node;
/**
* Clones a node.
*
* @param [deep=false] "true" to clone deep.
* @returns Cloned node.
*/
[PropertySymbol.cloneNode](deep?: boolean): Node;
/**
* Append a child node to childNodes.
*
* @param node Node to append.
* @param [disableValidations=false] "true" to disable validations.
* @returns Appended node.
*/
[PropertySymbol.appendChild](node: Node, disableValidations?: boolean): Node;
/**
* Remove Child element from childNodes array.
*
* @param node Node to remove.
* @returns Removed node.
*/
[PropertySymbol.removeChild](node: Node): Node;
/**
* Inserts a node before another.
*
* @param newNode Node to insert.
* @param referenceNode Node to insert before.
* @param [disableValidations=false] "true" to disable validations.
* @returns Inserted node.
*/
[PropertySymbol.insertBefore](newNode: Node, referenceNode: Node | null, disableValidations?: boolean): Node;
/**
* Replaces a node with another.
*
* @param newChild New child.
* @param oldChild Old child.
* @returns Replaced node.
*/
[PropertySymbol.replaceChild](newChild: Node, oldChild: Node): Node;
/**
* Compares two nodes.
* Two nodes are equal if they have the same type, defining the same attributes, and so on.
*
* @param node Node to compare.
* @returns boolean - `true` if two nodes are equal.
*/
isEqualNode(node: Node): boolean;
/**
* Converts the node to a string.
*
* @param listener Listener.
*/
toString(): string;
/**
* Observeres mutations on the node.
*
* Used by MutationObserver and internal logic.
*
* @param listener Listener.
*/
[PropertySymbol.observeMutations](listener: IMutationListener): void;
/**
* Stops observing mutations on the node.
*
* Used by MutationObserver and internal logic.
*
* @param listener Listener.
*/
[PropertySymbol.unobserveMutations](listener: IMutationListener): void;
/**
* Reports a mutation on the node.
*
* Used by MutationObserver and internal logic.
*
* @param record Mutation record.
*/
[PropertySymbol.reportMutation](record: MutationRecord): void;
/**
* Clears query selector cache.
*/
[PropertySymbol.clearCache](): void;
/**
* Called when connected to a node.
*/
[PropertySymbol.connectedToNode](): void;
/**
* Called when disconnected from a node.
*/
[PropertySymbol.disconnectedFromNode](): void;
/**
* Called when connected to document.
*/
[PropertySymbol.connectedToDocument](): void;
/**
* Called when disconnected from document.
*/
[PropertySymbol.disconnectedFromDocument](): void;
/**
* Reports the position of its argument node relative to the node on which it is called.
*
* @see https://dom.spec.whatwg.org/#dom-node-comparedocumentposition
* @param otherNode Other node.
*/
compareDocumentPosition(otherNode: Node): number;
/**
* Normalizes the sub-tree of the node, i.e. joins adjacent text nodes, and
* removes all empty text nodes.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/normalize
*/
normalize(): void;
/**
* Determines whether the given node is equal to the current node.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/Node/isSameNode
* @param node Node to check.
* @returns True if the given node is equal to the current node, otherwise false.
*/
isSameNode(node: Node): boolean;
}
//# sourceMappingURL=Node.d.ts.map

File diff suppressed because one or more lines are too long

1051
frontend/node_modules/happy-dom/lib/nodes/node/Node.js generated vendored Normal file

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,10 @@
declare enum NodeDocumentPositionEnum {
disconnect = 1,
preceding = 2,
following = 4,
contains = 8,
containedBy = 16,
implementationSpecific = 32
}
export default NodeDocumentPositionEnum;
//# sourceMappingURL=NodeDocumentPositionEnum.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"NodeDocumentPositionEnum.d.ts","sourceRoot":"","sources":["../../../src/nodes/node/NodeDocumentPositionEnum.ts"],"names":[],"mappings":"AAAA,aAAK,wBAAwB;IAC5B,UAAU,IAAO;IACjB,SAAS,IAAO;IAChB,SAAS,IAAO;IAChB,QAAQ,IAAO;IACf,WAAW,KAAO;IAClB,sBAAsB,KAAO;CAC7B;AAED,eAAe,wBAAwB,CAAC"}

View File

@@ -0,0 +1,11 @@
var NodeDocumentPositionEnum;
(function (NodeDocumentPositionEnum) {
NodeDocumentPositionEnum[NodeDocumentPositionEnum["disconnect"] = 1] = "disconnect";
NodeDocumentPositionEnum[NodeDocumentPositionEnum["preceding"] = 2] = "preceding";
NodeDocumentPositionEnum[NodeDocumentPositionEnum["following"] = 4] = "following";
NodeDocumentPositionEnum[NodeDocumentPositionEnum["contains"] = 8] = "contains";
NodeDocumentPositionEnum[NodeDocumentPositionEnum["containedBy"] = 16] = "containedBy";
NodeDocumentPositionEnum[NodeDocumentPositionEnum["implementationSpecific"] = 32] = "implementationSpecific";
})(NodeDocumentPositionEnum || (NodeDocumentPositionEnum = {}));
export default NodeDocumentPositionEnum;
//# sourceMappingURL=NodeDocumentPositionEnum.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"NodeDocumentPositionEnum.js","sourceRoot":"","sources":["../../../src/nodes/node/NodeDocumentPositionEnum.ts"],"names":[],"mappings":"AAAA,IAAK,wBAOJ;AAPD,WAAK,wBAAwB;IAC5B,mFAAiB,CAAA;IACjB,iFAAgB,CAAA;IAChB,iFAAgB,CAAA;IAChB,+EAAe,CAAA;IACf,sFAAkB,CAAA;IAClB,4GAA6B,CAAA;AAC9B,CAAC,EAPI,wBAAwB,KAAxB,wBAAwB,QAO5B;AAED,eAAe,wBAAwB,CAAC"}

View File

@@ -0,0 +1,81 @@
import * as PropertySymbol from '../../PropertySymbol.js';
import Node from './Node.js';
/**
* NodeList.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/NodeList
*/
declare class NodeList<T extends Node> {
[index: number]: T;
[PropertySymbol.items]: T[];
/**
* Constructor.
*
* @param illegalConstructorSymbol Illegal constructor symbol.
* @param items Items.
*/
constructor(illegalConstructorSymbol: symbol, items: T[]);
/**
* Returns length.
*
* @returns Length.
*/
get length(): number;
/**
* Returns `Symbol.toStringTag`.
*
* @returns `Symbol.toStringTag`.
*/
get [Symbol.toStringTag](): string;
/**
* Returns `[object NodeList]`.
*
* @returns `[object NodeList]`.
*/
toLocaleString(): string;
/**
* Returns `[object NodeList]`.
*
* @returns `[object NodeList]`.
*/
toString(): string;
/**
* Returns item by index.
*
* @param index Index.
*/
item(index: number): T;
/**
* Returns an iterator, allowing you to go through all values of the key/value pairs contained in this object.
*
* @returns Iterator.
*/
[Symbol.iterator](): IterableIterator<T>;
/**
* Returns an iterator, allowing you to go through all values of the key/value pairs contained in this object.
*
* @returns Iterator.
*/
values(): IterableIterator<T>;
/**
* Returns an iterator, allowing you to go through all key/value pairs contained in this object.
*
* @returns Iterator.
*/
entries(): IterableIterator<[number, T]>;
/**
* Executes a provided callback function once for each DOMTokenList element.
*
* @param callback Function.
* @param thisArg thisArg.
*/
forEach(callback: (currentValue: any, currentIndex: any, listObj: any) => void, thisArg?: this): void;
/**
* Returns an iterator, allowing you to go through all keys of the key/value pairs contained in this object.
*
* @returns Iterator.
*/
keys(): IterableIterator<number>;
}
export default NodeList;
//# sourceMappingURL=NodeList.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"NodeList.d.ts","sourceRoot":"","sources":["../../../src/nodes/node/NodeList.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAC;AAC1D,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B;;;;GAIG;AACH,cAAM,QAAQ,CAAC,CAAC,SAAS,IAAI;IAC5B,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC,CAAC;IACZ,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,CAAC,EAAE,CAAC;IAEnC;;;;;OAKG;gBACS,wBAAwB,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,EAAE;IAoGxD;;;;OAIG;IACH,IAAW,MAAM,IAAI,MAAM,CAE1B;IAED;;;;OAIG;IACH,IAAW,CAAC,MAAM,CAAC,WAAW,CAAC,IAAI,MAAM,CAExC;IAED;;;;OAIG;IACI,cAAc,IAAI,MAAM;IAI/B;;;;OAIG;IACI,QAAQ,IAAI,MAAM;IAIzB;;;;OAIG;IACI,IAAI,CAAC,KAAK,EAAE,MAAM,GAAG,CAAC;IAK7B;;;;OAIG;IACI,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,gBAAgB,CAAC,CAAC,CAAC;IAK/C;;;;OAIG;IACI,MAAM,IAAI,gBAAgB,CAAC,CAAC,CAAC;IAIpC;;;;OAIG;IACI,OAAO,IAAI,gBAAgB,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC,CAAC;IAI/C;;;;;OAKG;IACI,OAAO,CAAC,QAAQ,EAAE,CAAC,YAAY,KAAA,EAAE,YAAY,KAAA,EAAE,OAAO,KAAA,KAAK,IAAI,EAAE,OAAO,CAAC,EAAE,IAAI,GAAG,IAAI;IAI7F;;;;OAIG;IACI,IAAI,IAAI,gBAAgB,CAAC,MAAM,CAAC;CAGvC;AAED,eAAe,QAAQ,CAAC"}

View File

@@ -0,0 +1,185 @@
import ClassMethodBinder from '../../utilities/ClassMethodBinder.js';
import * as PropertySymbol from '../../PropertySymbol.js';
/**
* NodeList.
*
* @see https://developer.mozilla.org/en-US/docs/Web/API/NodeList
*/
class NodeList {
[PropertySymbol.items];
/**
* Constructor.
*
* @param illegalConstructorSymbol Illegal constructor symbol.
* @param items Items.
*/
constructor(illegalConstructorSymbol, items) {
if (illegalConstructorSymbol !== PropertySymbol.illegalConstructor) {
throw new TypeError('Illegal constructor');
}
this[PropertySymbol.items] = items;
const methodBinder = new ClassMethodBinder(this, this.constructor !== NodeList ? [this.constructor, NodeList] : [NodeList]);
const proxy = new Proxy(this, {
get: (target, property) => {
if (property === 'length') {
return items.length;
}
if (property in target || typeof property === 'symbol') {
methodBinder.bind(property);
return target[property];
}
if (property === '') {
return undefined;
}
const index = Number(property);
if (!isNaN(index)) {
return items[index];
}
},
set(target, property, newValue) {
methodBinder.bind(property);
if (typeof property === 'symbol') {
target[property] = newValue;
return true;
}
const index = Number(property);
if (isNaN(index)) {
target[property] = newValue;
}
return true;
},
deleteProperty(target, property) {
if (typeof property === 'symbol') {
delete target[property];
return true;
}
const index = Number(property);
if (isNaN(index)) {
delete target[property];
}
return true;
},
ownKeys() {
return Object.keys(items);
},
has(target, property) {
if (property in target) {
return true;
}
if (typeof property === 'symbol') {
return false;
}
const index = Number(property);
return !isNaN(index) && index >= 0 && index < items.length;
},
defineProperty(target, property, descriptor) {
methodBinder.preventBinding(property);
if (property in target) {
Object.defineProperty(target, property, descriptor);
return true;
}
return false;
},
getOwnPropertyDescriptor(target, property) {
if (property in target || typeof property === 'symbol') {
return;
}
const index = Number(property);
if (!isNaN(index) && items[index]) {
return {
value: items[index],
writable: false,
enumerable: true,
configurable: true
};
}
}
});
return proxy;
}
/**
* Returns length.
*
* @returns Length.
*/
get length() {
return this[PropertySymbol.items].length;
}
/**
* Returns `Symbol.toStringTag`.
*
* @returns `Symbol.toStringTag`.
*/
get [Symbol.toStringTag]() {
return 'NodeList';
}
/**
* Returns `[object NodeList]`.
*
* @returns `[object NodeList]`.
*/
toLocaleString() {
return '[object NodeList]';
}
/**
* Returns `[object NodeList]`.
*
* @returns `[object NodeList]`.
*/
toString() {
return '[object NodeList]';
}
/**
* Returns item by index.
*
* @param index Index.
*/
item(index) {
const nodes = this[PropertySymbol.items];
return index >= 0 && nodes[index] ? nodes[index] : null;
}
/**
* Returns an iterator, allowing you to go through all values of the key/value pairs contained in this object.
*
* @returns Iterator.
*/
[Symbol.iterator]() {
const items = this[PropertySymbol.items];
return items[Symbol.iterator]();
}
/**
* Returns an iterator, allowing you to go through all values of the key/value pairs contained in this object.
*
* @returns Iterator.
*/
values() {
return this[PropertySymbol.items].values();
}
/**
* Returns an iterator, allowing you to go through all key/value pairs contained in this object.
*
* @returns Iterator.
*/
entries() {
return this[PropertySymbol.items].entries();
}
/**
* Executes a provided callback function once for each DOMTokenList element.
*
* @param callback Function.
* @param thisArg thisArg.
*/
forEach(callback, thisArg) {
return this[PropertySymbol.items].forEach(callback, thisArg);
}
/**
* Returns an iterator, allowing you to go through all keys of the key/value pairs contained in this object.
*
* @returns Iterator.
*/
keys() {
return this[PropertySymbol.items].keys();
}
}
export default NodeList;
//# sourceMappingURL=NodeList.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"NodeList.js","sourceRoot":"","sources":["../../../src/nodes/node/NodeList.ts"],"names":[],"mappings":"AAAA,OAAO,iBAAiB,MAAM,sCAAsC,CAAC;AACrE,OAAO,KAAK,cAAc,MAAM,yBAAyB,CAAC;AAG1D;;;;GAIG;AACH,MAAM,QAAQ;IAEN,CAAC,cAAc,CAAC,KAAK,CAAC,CAAM;IAEnC;;;;;OAKG;IACH,YAAY,wBAAgC,EAAE,KAAU;QACvD,IAAI,wBAAwB,KAAK,cAAc,CAAC,kBAAkB,EAAE,CAAC;YACpE,MAAM,IAAI,SAAS,CAAC,qBAAqB,CAAC,CAAC;QAC5C,CAAC;QAED,IAAI,CAAC,cAAc,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC;QAEnC,MAAM,YAAY,GAAG,IAAI,iBAAiB,CACzC,IAAI,EACJ,IAAI,CAAC,WAAW,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,CACzE,CAAC;QAEF,MAAM,KAAK,GAAG,IAAI,KAAK,CAAC,IAAI,EAAE;YAC7B,GAAG,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE;g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AAC,KAAK,CAAE,CAAC,OAAO,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACrE,CAAC;IAED;;;;OAIG;IACI,IAAI;QACV,OAAa,IAAI,CAAC,cAAc,CAAC,KAAK,CAAE,CAAC,IAAI,EAAE,CAAC;IACjD,CAAC;CACD;AAED,eAAe,QAAQ,CAAC"}

View File

@@ -0,0 +1,13 @@
declare enum NodeTypeEnum {
elementNode = 1,
attributeNode = 2,
textNode = 3,
cdataSectionNode = 4,
commentNode = 8,
documentNode = 9,
documentTypeNode = 10,
documentFragmentNode = 11,
processingInstructionNode = 7
}
export default NodeTypeEnum;
//# sourceMappingURL=NodeTypeEnum.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"NodeTypeEnum.d.ts","sourceRoot":"","sources":["../../../src/nodes/node/NodeTypeEnum.ts"],"names":[],"mappings":"AAAA,aAAK,YAAY;IAChB,WAAW,IAAI;IACf,aAAa,IAAI;IACjB,QAAQ,IAAI;IACZ,gBAAgB,IAAI;IACpB,WAAW,IAAI;IACf,YAAY,IAAI;IAChB,gBAAgB,KAAK;IACrB,oBAAoB,KAAK;IACzB,yBAAyB,IAAI;CAC7B;AAED,eAAe,YAAY,CAAC"}

View File

@@ -0,0 +1,14 @@
var NodeTypeEnum;
(function (NodeTypeEnum) {
NodeTypeEnum[NodeTypeEnum["elementNode"] = 1] = "elementNode";
NodeTypeEnum[NodeTypeEnum["attributeNode"] = 2] = "attributeNode";
NodeTypeEnum[NodeTypeEnum["textNode"] = 3] = "textNode";
NodeTypeEnum[NodeTypeEnum["cdataSectionNode"] = 4] = "cdataSectionNode";
NodeTypeEnum[NodeTypeEnum["commentNode"] = 8] = "commentNode";
NodeTypeEnum[NodeTypeEnum["documentNode"] = 9] = "documentNode";
NodeTypeEnum[NodeTypeEnum["documentTypeNode"] = 10] = "documentTypeNode";
NodeTypeEnum[NodeTypeEnum["documentFragmentNode"] = 11] = "documentFragmentNode";
NodeTypeEnum[NodeTypeEnum["processingInstructionNode"] = 7] = "processingInstructionNode";
})(NodeTypeEnum || (NodeTypeEnum = {}));
export default NodeTypeEnum;
//# sourceMappingURL=NodeTypeEnum.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"NodeTypeEnum.js","sourceRoot":"","sources":["../../../src/nodes/node/NodeTypeEnum.ts"],"names":[],"mappings":"AAAA,IAAK,YAUJ;AAVD,WAAK,YAAY;IAChB,6DAAe,CAAA;IACf,iEAAiB,CAAA;IACjB,uDAAY,CAAA;IACZ,uEAAoB,CAAA;IACpB,6DAAe,CAAA;IACf,+DAAgB,CAAA;IAChB,wEAAqB,CAAA;IACrB,gFAAyB,CAAA;IACzB,yFAA6B,CAAA;AAC9B,CAAC,EAVI,YAAY,KAAZ,YAAY,QAUhB;AAED,eAAe,YAAY,CAAC"}

View File

@@ -0,0 +1,85 @@
import Text from '../text/Text.js';
import Node from './Node.js';
import Element from '../element/Element.js';
/**
* Node utility.
*/
export default class NodeUtility {
/**
* Returns whether the passed node is a text node, and narrows its type.
*
* @param node The node to be tested.
* @returns "true" if the node is a text node.
*/
static isTextNode(node: Node | null): node is Text;
/**
* Returns boolean indicating if "ancestorNode" is an inclusive ancestor of "referenceNode".
*
* Based on:
* https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/helpers/node.js
*
* @see https://dom.spec.whatwg.org/#concept-tree-inclusive-ancestor
* @param ancestorNode Ancestor node.
* @param referenceNode Reference node.
* @param [includeShadowRoots = false] Include shadow roots.
* @returns "true" if inclusive ancestor.
*/
static isInclusiveAncestor(ancestorNode: Node | null, referenceNode: Node | null, includeShadowRoots?: boolean): boolean;
/**
* Returns boolean indicating if nodeB is following nodeA in the document tree.
*
* Based on:
* https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/helpers/node.js
*
* @see https://dom.spec.whatwg.org/#concept-tree-following
* @param nodeA Node A.
* @param nodeB Node B.
* @returns "true" if following.
*/
static isFollowing(nodeA: Node, nodeB: Node): boolean;
/**
* Node length.
*
* Based on:
* https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/helpers/node.js
*
* @see https://dom.spec.whatwg.org/#concept-node-length
* @param node Node.
* @returns Node length.
*/
static getNodeLength(node: Node): number;
/**
* Returns boolean indicating if nodeB is following nodeA in the document tree.
*
* Based on:
* https://github.com/jsdom/js-symbol-tree/blob/master/lib/SymbolTree.js#L220
*
* @param node Node.
* @param [root] Root.
* @returns Following node.
*/
static following(node: Node, root?: Node): Node;
/**
* Returns the next sibling or parents sibling.
*
* @param node Node.
* @returns Next descendant node.
*/
static nextDescendantNode(node: Node): Node;
/**
* Needed by https://dom.spec.whatwg.org/#concept-node-equals
*
* @param elementA
* @param elementB
*/
static attributeListsEqual(elementA: Element, elementB: Element): boolean;
/**
* Check if node nodeA equals node nodeB.
* Reference: https://dom.spec.whatwg.org/#concept-node-equals
*
* @param nodeA Node A.
* @param nodeB Node B.
*/
static isEqualNode(nodeA: Node, nodeB: Node): boolean;
}
//# sourceMappingURL=NodeUtility.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"NodeUtility.d.ts","sourceRoot":"","sources":["../../../src/nodes/node/NodeUtility.ts"],"names":[],"mappings":"AAAA,OAAO,IAAI,MAAM,iBAAiB,CAAC;AAGnC,OAAO,IAAI,MAAM,WAAW,CAAC;AAE7B,OAAO,OAAO,MAAM,uBAAuB,CAAC;AAM5C;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,WAAW;IAC/B;;;;;OAKG;WACW,UAAU,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI,GAAG,IAAI,IAAI,IAAI;IAIzD;;;;;;;;;;;OAWG;WACW,mBAAmB,CAChC,YAAY,EAAE,IAAI,GAAG,IAAI,EACzB,aAAa,EAAE,IAAI,GAAG,IAAI,EAC1B,kBAAkB,UAAQ,GACxB,OAAO;IA6CV;;;;;;;;;;OAUG;WACW,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,OAAO;IAkB5D;;;;;;;;;OASG;WACW,aAAa,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM;IAe/C;;;;;;;;;OASG;WACW,SAAS,CAAC,IAAI,EAAE,IAAI,EAAE,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI;IA0BtD;;;;;OAKG;WACW,kBAAkB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAYlD;;;;;OAKG;WACW,mBAAmB,CAAC,QAAQ,EAAE,OAAO,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO;IA0BhF;;;;;;OAMG;WACW,WAAW,CAAC,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,OAAO;CA4F5D"}

View File

@@ -0,0 +1,250 @@
import * as PropertySymbol from '../../PropertySymbol.js';
import NodeTypeEnum from './NodeTypeEnum.js';
/**
* Node utility.
*/
export default class NodeUtility {
/**
* Returns whether the passed node is a text node, and narrows its type.
*
* @param node The node to be tested.
* @returns "true" if the node is a text node.
*/
static isTextNode(node) {
return node?.[PropertySymbol.nodeType] === NodeTypeEnum.textNode;
}
/**
* Returns boolean indicating if "ancestorNode" is an inclusive ancestor of "referenceNode".
*
* Based on:
* https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/helpers/node.js
*
* @see https://dom.spec.whatwg.org/#concept-tree-inclusive-ancestor
* @param ancestorNode Ancestor node.
* @param referenceNode Reference node.
* @param [includeShadowRoots = false] Include shadow roots.
* @returns "true" if inclusive ancestor.
*/
static isInclusiveAncestor(ancestorNode, referenceNode, includeShadowRoots = false) {
if (ancestorNode === null || referenceNode === null) {
return false;
}
if (ancestorNode === referenceNode) {
return true;
}
if (!ancestorNode[PropertySymbol.nodeArray].length) {
return false;
}
if (includeShadowRoots &&
referenceNode[PropertySymbol.isConnected] !== ancestorNode[PropertySymbol.isConnected]) {
return false;
}
if (includeShadowRoots &&
ancestorNode === referenceNode[PropertySymbol.ownerDocument] &&
referenceNode[PropertySymbol.isConnected]) {
return true;
}
let parent = referenceNode[PropertySymbol.parentNode];
while (parent) {
if (ancestorNode === parent) {
return true;
}
parent = parent[PropertySymbol.parentNode]
? parent[PropertySymbol.parentNode]
: includeShadowRoots && parent.host
? parent.host
: null;
}
return false;
}
/**
* Returns boolean indicating if nodeB is following nodeA in the document tree.
*
* Based on:
* https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/helpers/node.js
*
* @see https://dom.spec.whatwg.org/#concept-tree-following
* @param nodeA Node A.
* @param nodeB Node B.
* @returns "true" if following.
*/
static isFollowing(nodeA, nodeB) {
if (nodeA === nodeB) {
return false;
}
let current = nodeB;
while (current) {
current = this.following(current);
if (current === nodeA) {
return true;
}
}
return false;
}
/**
* Node length.
*
* Based on:
* https://github.com/jsdom/jsdom/blob/master/lib/jsdom/living/helpers/node.js
*
* @see https://dom.spec.whatwg.org/#concept-node-length
* @param node Node.
* @returns Node length.
*/
static getNodeLength(node) {
switch (node[PropertySymbol.nodeType]) {
case NodeTypeEnum.documentTypeNode:
return 0;
case NodeTypeEnum.textNode:
case NodeTypeEnum.processingInstructionNode:
case NodeTypeEnum.commentNode:
return node.data.length;
default:
return node[PropertySymbol.nodeArray].length;
}
}
/**
* Returns boolean indicating if nodeB is following nodeA in the document tree.
*
* Based on:
* https://github.com/jsdom/js-symbol-tree/blob/master/lib/SymbolTree.js#L220
*
* @param node Node.
* @param [root] Root.
* @returns Following node.
*/
static following(node, root) {
const firstChild = node.firstChild;
if (firstChild) {
return firstChild;
}
let current = node;
while (current) {
if (current === root) {
return null;
}
const nextSibling = current.nextSibling;
if (nextSibling) {
return nextSibling;
}
current = current[PropertySymbol.parentNode];
}
return null;
}
/**
* Returns the next sibling or parents sibling.
*
* @param node Node.
* @returns Next descendant node.
*/
static nextDescendantNode(node) {
while (node && !node.nextSibling) {
node = node[PropertySymbol.parentNode];
}
if (!node) {
return null;
}
return node.nextSibling;
}
/**
* Needed by https://dom.spec.whatwg.org/#concept-node-equals
*
* @param elementA
* @param elementB
*/
static attributeListsEqual(elementA, elementB) {
const attributesA = Array.from(elementA[PropertySymbol.attributes][PropertySymbol.items].values());
const attributesB = Array.from(elementB[PropertySymbol.attributes][PropertySymbol.items].values());
for (const attributeA of attributesA) {
let found = false;
for (const attributeB of attributesB) {
if (attributeA[PropertySymbol.namespaceURI] === attributeB[PropertySymbol.namespaceURI] &&
attributeA.localName === attributeB.localName &&
attributeA[PropertySymbol.value] === attributeB[PropertySymbol.value]) {
found = true;
break;
}
}
if (!found) {
return false;
}
}
return true;
}
/**
* Check if node nodeA equals node nodeB.
* Reference: https://dom.spec.whatwg.org/#concept-node-equals
*
* @param nodeA Node A.
* @param nodeB Node B.
*/
static isEqualNode(nodeA, nodeB) {
if (nodeA[PropertySymbol.nodeType] !== nodeB[PropertySymbol.nodeType]) {
return false;
}
switch (nodeA[PropertySymbol.nodeType]) {
case NodeTypeEnum.documentTypeNode:
const documentTypeA = nodeA;
const documentTypeB = nodeB;
if (documentTypeA.name !== documentTypeB.name ||
documentTypeA.publicId !== documentTypeB.publicId ||
documentTypeA.systemId !== documentTypeB.systemId) {
return false;
}
break;
case NodeTypeEnum.elementNode:
const elementA = nodeA;
const elementB = nodeB;
if (elementA[PropertySymbol.namespaceURI] !== elementB[PropertySymbol.namespaceURI] ||
elementA[PropertySymbol.prefix] !== elementB[PropertySymbol.prefix] ||
elementA[PropertySymbol.localName] !== elementB[PropertySymbol.localName] ||
elementA[PropertySymbol.attributes][PropertySymbol.items].size !==
elementB[PropertySymbol.attributes][PropertySymbol.items].size) {
return false;
}
break;
case NodeTypeEnum.attributeNode:
const attributeA = nodeA;
const attributeB = nodeB;
if (attributeA[PropertySymbol.namespaceURI] !== attributeB[PropertySymbol.namespaceURI] ||
attributeA.localName !== attributeB.localName ||
attributeA[PropertySymbol.value] !== attributeB[PropertySymbol.value]) {
return false;
}
break;
case NodeTypeEnum.processingInstructionNode:
const processingInstructionA = nodeA;
const processingInstructionB = nodeB;
if (processingInstructionA.target !== processingInstructionB.target ||
processingInstructionA.data !== processingInstructionB.data) {
return false;
}
break;
case NodeTypeEnum.textNode:
case NodeTypeEnum.commentNode:
const textOrCommentA = nodeA;
const textOrCommentB = nodeB;
if (textOrCommentA.data !== textOrCommentB.data) {
return false;
}
break;
}
if (nodeA[PropertySymbol.nodeType] === NodeTypeEnum.elementNode &&
!NodeUtility.attributeListsEqual(nodeA, nodeB)) {
return false;
}
if (nodeA[PropertySymbol.nodeArray].length !==
nodeB[PropertySymbol.nodeArray].length) {
return false;
}
for (let i = 0; i < nodeA[PropertySymbol.nodeArray].length; i++) {
const childNodeA = nodeA[PropertySymbol.nodeArray][i];
const childNodeB = nodeB[PropertySymbol.nodeArray][i];
if (!NodeUtility.isEqualNode(childNodeA, childNodeB)) {
return false;
}
}
return true;
}
}
//# sourceMappingURL=NodeUtility.js.map

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,3 @@
type TNodeListListener<T> = (item: T, referenceItem?: T | null) => void;
export default TNodeListListener;
//# sourceMappingURL=TNodeListListener.d.ts.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"TNodeListListener.d.ts","sourceRoot":"","sources":["../../../src/nodes/node/TNodeListListener.ts"],"names":[],"mappings":"AAAA,KAAK,iBAAiB,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,EAAE,aAAa,CAAC,EAAE,CAAC,GAAG,IAAI,KAAK,IAAI,CAAC;AACxE,eAAe,iBAAiB,CAAC"}

View File

@@ -0,0 +1,2 @@
export {};
//# sourceMappingURL=TNodeListListener.js.map

View File

@@ -0,0 +1 @@
{"version":3,"file":"TNodeListListener.js","sourceRoot":"","sources":["../../../src/nodes/node/TNodeListListener.ts"],"names":[],"mappings":""}