refactor(core): remove testing-only node getters and invoke() from DomAdapters (#32291)
PR Close #32291
This commit is contained in:
parent
c0680602f9
commit
cb5701f8d9
|
@ -1494,8 +1494,7 @@ function declareTests(config?: {useJit: boolean}) {
|
|||
expect(noSelectorComponentFactory.selector).toBe('ng-component');
|
||||
|
||||
expect(
|
||||
getDOM()
|
||||
.nodeName(noSelectorComponentFactory.create(Injector.NULL).location.nativeElement)
|
||||
noSelectorComponentFactory.create(Injector.NULL).location.nativeElement.nodeName
|
||||
.toLowerCase())
|
||||
.toEqual('ng-component');
|
||||
});
|
||||
|
@ -1534,7 +1533,7 @@ function declareTests(config?: {useJit: boolean}) {
|
|||
throw 'Should throw';
|
||||
} catch (e) {
|
||||
const c = getDebugContext(e);
|
||||
expect(getDOM().nodeName(c.componentRenderElement).toUpperCase()).toEqual('DIV');
|
||||
expect(c.componentRenderElement.nodeName.toUpperCase()).toEqual('DIV');
|
||||
expect((<Injector>c.injector).get).toBeTruthy();
|
||||
}
|
||||
});
|
||||
|
@ -1550,8 +1549,8 @@ function declareTests(config?: {useJit: boolean}) {
|
|||
throw 'Should throw';
|
||||
} catch (e) {
|
||||
const c = getDebugContext(e);
|
||||
expect(getDOM().nodeName(c.renderNode).toUpperCase()).toEqual('INPUT');
|
||||
expect(getDOM().nodeName(c.componentRenderElement).toUpperCase()).toEqual('DIV');
|
||||
expect(c.renderNode.nodeName.toUpperCase()).toEqual('INPUT');
|
||||
expect(c.componentRenderElement.nodeName.toUpperCase()).toEqual('DIV');
|
||||
expect((<Injector>c.injector).get).toBeTruthy();
|
||||
expect(c.context).toEqual(fixture.componentInstance);
|
||||
expect(c.references['local']).toBeDefined();
|
||||
|
@ -1595,8 +1594,8 @@ function declareTests(config?: {useJit: boolean}) {
|
|||
|
||||
expect(err).toBeTruthy();
|
||||
const c = getDebugContext(err);
|
||||
expect(getDOM().nodeName(c.renderNode).toUpperCase()).toEqual('SPAN');
|
||||
expect(getDOM().nodeName(c.componentRenderElement).toUpperCase()).toEqual('DIV');
|
||||
expect(c.renderNode.nodeName.toUpperCase()).toEqual('SPAN');
|
||||
expect(c.componentRenderElement.nodeName.toUpperCase()).toEqual('DIV');
|
||||
expect((<Injector>c.injector).get).toBeTruthy();
|
||||
expect(c.context).toEqual(fixture.componentInstance);
|
||||
expect(c.references['local']).toBeDefined();
|
||||
|
|
|
@ -43,7 +43,7 @@ const addEventListener = '__zone_symbol__addEventListener' as 'addEventListener'
|
|||
expect(compView.component).toBe(instance);
|
||||
|
||||
const compRootEl = rootNodes[0].childNodes[0];
|
||||
expect(getDOM().nodeName(compRootEl).toLowerCase()).toBe('span');
|
||||
expect(compRootEl.nodeName.toLowerCase()).toBe('span');
|
||||
});
|
||||
|
||||
if (isBrowser()) {
|
||||
|
|
|
@ -32,7 +32,7 @@ const removeEventListener = '__zone_symbol__removeEventListener' as 'removeEvent
|
|||
elementDef(0, NodeFlags.None, null, null, 0, 'span')
|
||||
])).rootNodes;
|
||||
expect(rootNodes.length).toBe(1);
|
||||
expect(getDOM().nodeName(rootNodes[0]).toLowerCase()).toBe('span');
|
||||
expect(rootNodes[0].nodeName.toLowerCase()).toBe('span');
|
||||
});
|
||||
|
||||
it('should create views with multiple root elements', () => {
|
||||
|
@ -50,7 +50,7 @@ const removeEventListener = '__zone_symbol__removeEventListener' as 'removeEvent
|
|||
])).rootNodes;
|
||||
expect(rootNodes.length).toBe(1);
|
||||
const spanEl = rootNodes[0].childNodes[0];
|
||||
expect(getDOM().nodeName(spanEl).toLowerCase()).toBe('span');
|
||||
expect(spanEl.nodeName.toLowerCase()).toBe('span');
|
||||
});
|
||||
|
||||
it('should set fixed attributes', () => {
|
||||
|
|
|
@ -80,7 +80,6 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
|||
hasProperty(element: Node, name: string): boolean { return name in element; }
|
||||
setProperty(el: Node, name: string, value: any) { (<any>el)[name] = value; }
|
||||
getProperty(el: Node, name: string): any { return (<any>el)[name]; }
|
||||
invoke(el: Node, methodName: string, args: any[]): any { (<any>el)[methodName](...args); }
|
||||
|
||||
// TODO(tbosch): move this into a separate environment class once we have it
|
||||
logError(error: string): void {
|
||||
|
@ -139,9 +138,6 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
|||
isPrevented(evt: Event): boolean {
|
||||
return evt.defaultPrevented || evt.returnValue != null && !evt.returnValue;
|
||||
}
|
||||
nodeName(node: Node): string { return node.nodeName; }
|
||||
nodeValue(node: Node): string|null { return node.nodeValue; }
|
||||
type(node: HTMLInputElement): string { return node.type; }
|
||||
nextSibling(el: Node): Node|null { return el.nextSibling; }
|
||||
parentElement(el: Node): Node|null { return el.parentNode; }
|
||||
clearNodes(el: Node) {
|
||||
|
|
|
@ -35,7 +35,6 @@ export abstract class DomAdapter {
|
|||
abstract hasProperty(element: any, name: string): boolean;
|
||||
abstract setProperty(el: Element, name: string, value: any): any;
|
||||
abstract getProperty(el: Element, name: string): any;
|
||||
abstract invoke(el: Element, methodName: string, args: any[]): any;
|
||||
|
||||
abstract logError(error: any): any;
|
||||
abstract log(error: any): any;
|
||||
|
@ -53,17 +52,14 @@ export abstract class DomAdapter {
|
|||
abstract createEvent(eventType: string): any;
|
||||
abstract preventDefault(evt: any): any;
|
||||
abstract isPrevented(evt: any): boolean;
|
||||
abstract nodeName(node: any): string;
|
||||
abstract nodeValue(node: any): string|null;
|
||||
abstract type(node: any): string;
|
||||
abstract nextSibling(el: any): Node|null;
|
||||
abstract parentElement(el: any): Node|null;
|
||||
|
||||
// Used by Meta
|
||||
abstract remove(el: any): Node;
|
||||
abstract getAttribute(element: any, attribute: string): string|null;
|
||||
|
||||
// Used by platform-server
|
||||
abstract nextSibling(el: any): Node|null;
|
||||
abstract parentElement(el: any): Node|null;
|
||||
abstract clearNodes(el: any): any;
|
||||
abstract appendChild(el: any, node: any): any;
|
||||
abstract removeChild(el: any, node: any): any;
|
||||
|
|
|
@ -50,7 +50,6 @@ export class WorkerDomAdapter extends DomAdapter {
|
|||
hasProperty(element: any, name: string): boolean { throw 'not implemented'; }
|
||||
setProperty(el: Element, name: string, value: any) { throw 'not implemented'; }
|
||||
getProperty(el: Element, name: string): any { throw 'not implemented'; }
|
||||
invoke(el: Element, methodName: string, args: any[]): any { throw 'not implemented'; }
|
||||
|
||||
parse(templateHtml: string) { throw 'not implemented'; }
|
||||
querySelector(el: any, selector: string): HTMLElement { throw 'not implemented'; }
|
||||
|
@ -62,9 +61,6 @@ export class WorkerDomAdapter extends DomAdapter {
|
|||
createEvent(eventType: string): any { throw 'not implemented'; }
|
||||
preventDefault(evt: any) { throw 'not implemented'; }
|
||||
isPrevented(evt: any): boolean { throw 'not implemented'; }
|
||||
nodeName(node: any): string { throw 'not implemented'; }
|
||||
nodeValue(node: any): string { throw 'not implemented'; }
|
||||
type(node: any): string { throw 'not implemented'; }
|
||||
nextSibling(el: any): Node { throw 'not implemented'; }
|
||||
parentElement(el: any): Node { throw 'not implemented'; }
|
||||
clearNodes(el: any) { throw 'not implemented'; }
|
||||
|
|
Loading…
Reference in New Issue