refactor(core): remove testing-only DOM manipulation utils from DomAdapters (#32291)
PR Close #32291
This commit is contained in:

committed by
Miško Hevery

parent
ede5786d1e
commit
30dabdf8fc
@ -146,14 +146,6 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
nextSibling(el: Node): Node|null { return el.nextSibling; }
|
||||
parentElement(el: Node): Node|null { return el.parentNode; }
|
||||
childNodes(el: any): Node[] { return el.childNodes; }
|
||||
childNodesAsList(el: Node): any[] {
|
||||
const childNodes = el.childNodes;
|
||||
const res = [];
|
||||
for (let i = 0; i < childNodes.length; i++) {
|
||||
res[i] = childNodes[i];
|
||||
}
|
||||
return res;
|
||||
}
|
||||
clearNodes(el: Node) {
|
||||
while (el.firstChild) {
|
||||
el.removeChild(el.firstChild);
|
||||
@ -168,17 +160,9 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
return node;
|
||||
}
|
||||
insertBefore(parent: Node, ref: Node, node: Node) { parent.insertBefore(node, ref); }
|
||||
getText(el: Node): string|null { return el.textContent; }
|
||||
setText(el: Node, value: string) { el.textContent = value; }
|
||||
getValue(el: any): string { return el.value; }
|
||||
setValue(el: any, value: string) { el.value = value; }
|
||||
getChecked(el: any): boolean { return el.checked; }
|
||||
createComment(text: string): Comment { return this.getDefaultDocument().createComment(text); }
|
||||
createTemplate(html: any): HTMLElement {
|
||||
const t = this.getDefaultDocument().createElement('template');
|
||||
t.innerHTML = html;
|
||||
return t;
|
||||
}
|
||||
createElement(tagName: string, doc?: Document): HTMLElement {
|
||||
doc = doc || this.getDefaultDocument();
|
||||
return doc.createElement(tagName);
|
||||
@ -192,7 +176,6 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
return doc.createTextNode(text);
|
||||
}
|
||||
getHost(el: HTMLElement): HTMLElement { return (<any>el).host; }
|
||||
clone(node: Node): Node { return node.cloneNode(true); }
|
||||
getElementsByTagName(element: any, name: string): HTMLElement[] {
|
||||
return element.getElementsByTagName(name);
|
||||
}
|
||||
|
@ -19,6 +19,5 @@ import {DomAdapter} from '../dom/dom_adapter';
|
||||
export abstract class GenericBrowserDomAdapter extends DomAdapter {
|
||||
constructor() { super(); }
|
||||
|
||||
getDistributedNodes(el: HTMLElement): Node[] { return (<any>el).getDistributedNodes(); }
|
||||
supportsDOMEvents(): boolean { return true; }
|
||||
}
|
||||
|
@ -60,31 +60,22 @@ export abstract class DomAdapter {
|
||||
abstract nextSibling(el: any): Node|null;
|
||||
abstract parentElement(el: any): Node|null;
|
||||
abstract childNodes(el: any): Node[];
|
||||
abstract childNodesAsList(el: any): Node[];
|
||||
abstract clearNodes(el: any): any;
|
||||
abstract appendChild(el: any, node: any): any;
|
||||
abstract removeChild(el: any, node: any): any;
|
||||
abstract remove(el: any): Node;
|
||||
abstract insertBefore(parent: any, ref: any, node: any): any;
|
||||
abstract getText(el: any): string|null;
|
||||
abstract setText(el: any, value: string): any;
|
||||
abstract getValue(el: any): string;
|
||||
abstract setValue(el: any, value: string): any;
|
||||
abstract getChecked(el: any): boolean;
|
||||
abstract createComment(text: string): any;
|
||||
abstract createTemplate(html: any): HTMLElement;
|
||||
abstract createElement(tagName: any, doc?: any): HTMLElement;
|
||||
abstract createElementNS(ns: string, tagName: string, doc?: any): Element;
|
||||
abstract createTextNode(text: string, doc?: any): Text;
|
||||
abstract getHost(el: any): any;
|
||||
abstract getDistributedNodes(el: any): Node[];
|
||||
abstract clone /*<T extends Node>*/ (node: Node /*T*/): Node /*T*/;
|
||||
abstract getElementsByTagName(element: any, name: string): HTMLElement[];
|
||||
|
||||
// Used by Meta
|
||||
abstract remove(el: any): Node;
|
||||
abstract getAttribute(element: any, attribute: string): string|null;
|
||||
|
||||
// Used by platform-server
|
||||
abstract clearNodes(el: any): any;
|
||||
abstract appendChild(el: any, node: any): any;
|
||||
abstract removeChild(el: any, node: any): any;
|
||||
abstract insertBefore(parent: any, ref: any, node: any): any;
|
||||
abstract setText(el: any, value: string): any;
|
||||
abstract createComment(text: string): any;
|
||||
abstract createElement(tagName: any, doc?: any): HTMLElement;
|
||||
abstract createElementNS(ns: string, tagName: string, doc?: any): Element;
|
||||
abstract createTextNode(text: string, doc?: any): Text;
|
||||
abstract getElementsByTagName(element: any, name: string): HTMLElement[];
|
||||
abstract addClass(element: any, className: string): any;
|
||||
abstract removeClass(element: any, className: string): any;
|
||||
abstract getStyle(element: any, styleName: string): any;
|
||||
@ -107,6 +98,7 @@ export abstract class DomAdapter {
|
||||
|
||||
// Used by Testability
|
||||
abstract isShadowRoot(node: any): boolean;
|
||||
abstract getHost(el: any): any;
|
||||
|
||||
// Used by KeyEventsPlugin
|
||||
abstract getEventKey(event: any): string;
|
||||
|
Reference in New Issue
Block a user