Loading etc/browser.api.md +6 −0 Original line number Diff line number Diff line Loading @@ -477,6 +477,8 @@ export class HtmlElement extends DOMNode { // @internal (undocumented) readonly _adapter: HtmlElementLike; get annotatedName(): string; // (undocumented) append(node: DOMNode): void; appendText(text: string | DynamicValue, location: Location_2): void; get ariaLabelledby(): string[] | DynamicValue | null; // (undocumented) Loading Loading @@ -511,6 +513,8 @@ export class HtmlElement extends DOMNode { // (undocumented) hasAttribute(key: string): boolean; get id(): string | null; // (undocumented) insertBefore(node: DOMNode, reference: DOMNode | null): void; is(tagName: string): boolean; get lastElementChild(): HtmlElement | null; loadMeta(meta: MetaElement): void; Loading @@ -527,6 +531,8 @@ export class HtmlElement extends DOMNode { querySelector(selector: string): HtmlElement | null; // (undocumented) querySelectorAll(selector: string): HtmlElement[]; // (undocumented) removeChild<T extends DOMNode>(node: T): T; get role(): string | DynamicValue | null; // @internal (undocumented) static rootNode(location: Location_2): HtmlElement; Loading etc/index.api.md +6 −0 Original line number Diff line number Diff line Loading @@ -568,6 +568,8 @@ export class HtmlElement extends DOMNode { // @internal (undocumented) readonly _adapter: HtmlElementLike; get annotatedName(): string; // (undocumented) append(node: DOMNode): void; appendText(text: string | DynamicValue, location: Location_2): void; get ariaLabelledby(): string[] | DynamicValue | null; // (undocumented) Loading Loading @@ -602,6 +604,8 @@ export class HtmlElement extends DOMNode { // (undocumented) hasAttribute(key: string): boolean; get id(): string | null; // (undocumented) insertBefore(node: DOMNode, reference: DOMNode | null): void; is(tagName: string): boolean; get lastElementChild(): HtmlElement | null; loadMeta(meta: MetaElement): void; Loading @@ -618,6 +622,8 @@ export class HtmlElement extends DOMNode { querySelector(selector: string): HtmlElement | null; // (undocumented) querySelectorAll(selector: string): HtmlElement[]; // (undocumented) removeChild<T extends DOMNode>(node: T): T; get role(): string | DynamicValue | null; // @internal (undocumented) static rootNode(location: Location_2): HtmlElement; Loading src/dom/htmlelement.ts +22 −1 Original line number Diff line number Diff line Loading @@ -12,11 +12,13 @@ import { NodeType } from "./nodetype"; import { Selector, generateIdSelector } from "./selector"; import { TextNode } from "./text"; const CHILD_ELEMENTS = Symbol("childElements"); const ROLE = Symbol("role"); const TABINDEX = Symbol("tabindex"); declare module "./cache" { export interface DOMNodeCache { [CHILD_ELEMENTS]: HtmlElement[]; [ROLE]: string; [TABINDEX]: number | null; } Loading Loading @@ -249,7 +251,11 @@ export class HtmlElement extends DOMNode { * Similar to childNodes but only elements. */ public get childElements(): HtmlElement[] { return this.childNodes.filter(isElementNode); const cached = this.cacheGet(CHILD_ELEMENTS); if (cached !== undefined) { return cached; } return this.cacheSet(CHILD_ELEMENTS, this.childNodes.filter(isElementNode)); } /** Loading Loading @@ -734,12 +740,27 @@ export class HtmlElement extends DOMNode { return visit(this); } public override append(node: DOMNode): void { super.append(node); this.cacheRemove(CHILD_ELEMENTS); } public override insertBefore(node: DOMNode, reference: DOMNode | null): void { super.insertBefore(node, reference); this.cacheRemove(CHILD_ELEMENTS); } public override removeChild<T extends DOMNode>(node: T): T { return super.removeChild(node); } /** * @internal */ public override _setParent(node: DOMNode | null): DOMNode | null { const oldParent = this._parent; this._parent = node instanceof HtmlElement ? node : null; oldParent?.cacheRemove(CHILD_ELEMENTS); return oldParent; } } Loading Loading
etc/browser.api.md +6 −0 Original line number Diff line number Diff line Loading @@ -477,6 +477,8 @@ export class HtmlElement extends DOMNode { // @internal (undocumented) readonly _adapter: HtmlElementLike; get annotatedName(): string; // (undocumented) append(node: DOMNode): void; appendText(text: string | DynamicValue, location: Location_2): void; get ariaLabelledby(): string[] | DynamicValue | null; // (undocumented) Loading Loading @@ -511,6 +513,8 @@ export class HtmlElement extends DOMNode { // (undocumented) hasAttribute(key: string): boolean; get id(): string | null; // (undocumented) insertBefore(node: DOMNode, reference: DOMNode | null): void; is(tagName: string): boolean; get lastElementChild(): HtmlElement | null; loadMeta(meta: MetaElement): void; Loading @@ -527,6 +531,8 @@ export class HtmlElement extends DOMNode { querySelector(selector: string): HtmlElement | null; // (undocumented) querySelectorAll(selector: string): HtmlElement[]; // (undocumented) removeChild<T extends DOMNode>(node: T): T; get role(): string | DynamicValue | null; // @internal (undocumented) static rootNode(location: Location_2): HtmlElement; Loading
etc/index.api.md +6 −0 Original line number Diff line number Diff line Loading @@ -568,6 +568,8 @@ export class HtmlElement extends DOMNode { // @internal (undocumented) readonly _adapter: HtmlElementLike; get annotatedName(): string; // (undocumented) append(node: DOMNode): void; appendText(text: string | DynamicValue, location: Location_2): void; get ariaLabelledby(): string[] | DynamicValue | null; // (undocumented) Loading Loading @@ -602,6 +604,8 @@ export class HtmlElement extends DOMNode { // (undocumented) hasAttribute(key: string): boolean; get id(): string | null; // (undocumented) insertBefore(node: DOMNode, reference: DOMNode | null): void; is(tagName: string): boolean; get lastElementChild(): HtmlElement | null; loadMeta(meta: MetaElement): void; Loading @@ -618,6 +622,8 @@ export class HtmlElement extends DOMNode { querySelector(selector: string): HtmlElement | null; // (undocumented) querySelectorAll(selector: string): HtmlElement[]; // (undocumented) removeChild<T extends DOMNode>(node: T): T; get role(): string | DynamicValue | null; // @internal (undocumented) static rootNode(location: Location_2): HtmlElement; Loading
src/dom/htmlelement.ts +22 −1 Original line number Diff line number Diff line Loading @@ -12,11 +12,13 @@ import { NodeType } from "./nodetype"; import { Selector, generateIdSelector } from "./selector"; import { TextNode } from "./text"; const CHILD_ELEMENTS = Symbol("childElements"); const ROLE = Symbol("role"); const TABINDEX = Symbol("tabindex"); declare module "./cache" { export interface DOMNodeCache { [CHILD_ELEMENTS]: HtmlElement[]; [ROLE]: string; [TABINDEX]: number | null; } Loading Loading @@ -249,7 +251,11 @@ export class HtmlElement extends DOMNode { * Similar to childNodes but only elements. */ public get childElements(): HtmlElement[] { return this.childNodes.filter(isElementNode); const cached = this.cacheGet(CHILD_ELEMENTS); if (cached !== undefined) { return cached; } return this.cacheSet(CHILD_ELEMENTS, this.childNodes.filter(isElementNode)); } /** Loading Loading @@ -734,12 +740,27 @@ export class HtmlElement extends DOMNode { return visit(this); } public override append(node: DOMNode): void { super.append(node); this.cacheRemove(CHILD_ELEMENTS); } public override insertBefore(node: DOMNode, reference: DOMNode | null): void { super.insertBefore(node, reference); this.cacheRemove(CHILD_ELEMENTS); } public override removeChild<T extends DOMNode>(node: T): T { return super.removeChild(node); } /** * @internal */ public override _setParent(node: DOMNode | null): DOMNode | null { const oldParent = this._parent; this._parent = node instanceof HtmlElement ? node : null; oldParent?.cacheRemove(CHILD_ELEMENTS); return oldParent; } } Loading