refactor(core): remove testing-only childNodes() and firstChild() fns from DomAdapters (#32291)
PR Close #32291
This commit is contained in:

committed by
Miško Hevery

parent
30dabdf8fc
commit
c0680602f9
@ -142,10 +142,8 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||
nodeName(node: Node): string { return node.nodeName; }
|
||||
nodeValue(node: Node): string|null { return node.nodeValue; }
|
||||
type(node: HTMLInputElement): string { return node.type; }
|
||||
firstChild(el: Node): Node|null { return el.firstChild; }
|
||||
nextSibling(el: Node): Node|null { return el.nextSibling; }
|
||||
parentElement(el: Node): Node|null { return el.parentNode; }
|
||||
childNodes(el: any): Node[] { return el.childNodes; }
|
||||
clearNodes(el: Node) {
|
||||
while (el.firstChild) {
|
||||
el.removeChild(el.firstChild);
|
||||
|
@ -56,10 +56,8 @@ export abstract class DomAdapter {
|
||||
abstract nodeName(node: any): string;
|
||||
abstract nodeValue(node: any): string|null;
|
||||
abstract type(node: any): string;
|
||||
abstract firstChild(el: any): Node|null;
|
||||
abstract nextSibling(el: any): Node|null;
|
||||
abstract parentElement(el: any): Node|null;
|
||||
abstract childNodes(el: any): Node[];
|
||||
|
||||
// Used by Meta
|
||||
abstract remove(el: any): Node;
|
||||
|
@ -63,7 +63,7 @@ import {el} from '../../../testing/src/browser_util';
|
||||
// Workaround for https://bugs.webkit.org/show_bug.cgi?id=122755
|
||||
getDOM().appendChild(doc.body, element);
|
||||
|
||||
const child = getDOM().firstChild(element);
|
||||
const child = element.firstChild;
|
||||
const dispatchedEvent = getDOM().createMouseEvent('click');
|
||||
let receivedEvent: any /** TODO #9100 */ = null;
|
||||
const handler = (e: any /** TODO #9100 */) => { receivedEvent = e; };
|
||||
|
@ -95,7 +95,7 @@ export function dispatchEvent(element: any, eventType: any): void {
|
||||
}
|
||||
|
||||
export function el(html: string): HTMLElement {
|
||||
return <HTMLElement>getDOM().firstChild(getContent(createTemplate(html)));
|
||||
return <HTMLElement>getContent(createTemplate(html)).firstChild;
|
||||
}
|
||||
|
||||
export function normalizeCSS(css: string): string {
|
||||
@ -148,7 +148,7 @@ export function stringifyElement(el: any /** TODO #9100 */): string {
|
||||
|
||||
// Children
|
||||
const childrenRoot = templateAwareRoot(el);
|
||||
const children = childrenRoot ? getDOM().childNodes(childrenRoot) : [];
|
||||
const children = childrenRoot ? childrenRoot.childNodes : [];
|
||||
for (let j = 0; j < children.length; j++) {
|
||||
result += stringifyElement(children[j]);
|
||||
}
|
||||
|
@ -280,7 +280,7 @@ _global.beforeEach(function() {
|
||||
|
||||
function elementText(n: any): string {
|
||||
const hasNodes = (n: any) => {
|
||||
const children = getDOM().childNodes(n);
|
||||
const children = n.childNodes;
|
||||
return children && children.length > 0;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user