refactor(core): remove misc dom utils from DomAdapters (#32278)
PR Close #32278
This commit is contained in:
@ -11,7 +11,7 @@ import {MockResourceLoader} from '@angular/compiler/testing';
|
||||
import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ContentChild, DebugElement, Directive, DoCheck, EventEmitter, HostBinding, Inject, Injectable, Input, OnChanges, OnDestroy, OnInit, Output, Pipe, PipeTransform, Provider, RenderComponentType, Renderer, RendererFactory2, RendererType2, RootRenderer, SimpleChange, SimpleChanges, TemplateRef, Type, ViewChild, ViewContainerRef, WrappedValue} from '@angular/core';
|
||||
import {ComponentFixture, TestBed, fakeAsync} from '@angular/core/testing';
|
||||
import {By} from '@angular/platform-browser/src/dom/debug/by';
|
||||
import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter';
|
||||
import {isTextNode} from '@angular/platform-browser/testing/src/browser_util';
|
||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||
import {ivyEnabled, modifiedInIvy, onlyInIvy} from '@angular/private/testing';
|
||||
|
||||
@ -1731,7 +1731,7 @@ function patchLoggingRenderer2(rendererFactory: RendererFactory2, log: RenderLog
|
||||
origSetProperty.call(renderer, el, name, value);
|
||||
};
|
||||
renderer.setValue = function(node: any, value: string): void {
|
||||
if (getDOM().isTextNode(node)) {
|
||||
if (isTextNode(node)) {
|
||||
log.setText(node, value);
|
||||
}
|
||||
origSetValue.call(renderer, node, value);
|
||||
|
@ -137,8 +137,7 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
|
||||
fixture.componentInstance.ctxProp = null !;
|
||||
fixture.detectChanges();
|
||||
expect(getDOM().hasAttribute(fixture.debugElement.children[0].nativeElement, 'foo'))
|
||||
.toBeFalsy();
|
||||
expect(fixture.debugElement.children[0].nativeElement.hasAttribute('foo')).toBeFalsy();
|
||||
});
|
||||
|
||||
it('should remove style when when style expression evaluates to null', () => {
|
||||
|
@ -60,7 +60,7 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
const children = getDOM().childNodes(el);
|
||||
expect(children.length).toBe(2);
|
||||
expect(isCommentNode(children[0])).toBe(true);
|
||||
expect(getDOM().tagName(children[1]).toUpperCase()).toEqual('P');
|
||||
expect((children[1] as Element).tagName.toUpperCase()).toEqual('P');
|
||||
});
|
||||
|
||||
modifiedInIvy('FW-678: ivy generates different DOM structure for <ng-container>')
|
||||
@ -99,8 +99,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(isCommentNode(children[0])).toBe(true);
|
||||
// ng-container anchor
|
||||
expect(isCommentNode(children[1])).toBe(true);
|
||||
expect(getDOM().tagName(children[2]).toUpperCase()).toEqual('P');
|
||||
expect(getDOM().tagName(children[3]).toUpperCase()).toEqual('B');
|
||||
expect((children[2] as Element).tagName.toUpperCase()).toEqual('P');
|
||||
expect((children[3] as Element).tagName.toUpperCase()).toEqual('B');
|
||||
|
||||
fixture.componentInstance.ctxBoolProp = false;
|
||||
fixture.detectChanges();
|
||||
|
@ -980,7 +980,7 @@ class Tree {
|
||||
class CmpD {
|
||||
tagName: string;
|
||||
constructor(elementRef: ElementRef) {
|
||||
this.tagName = getDOM().tagName(elementRef.nativeElement).toLowerCase();
|
||||
this.tagName = elementRef.nativeElement.tagName.toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
@ -989,7 +989,7 @@ class CmpD {
|
||||
class CmpC {
|
||||
tagName: string;
|
||||
constructor(elementRef: ElementRef) {
|
||||
this.tagName = getDOM().tagName(elementRef.nativeElement).toLowerCase();
|
||||
this.tagName = elementRef.nativeElement.tagName.toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -418,7 +418,7 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
const compRef =
|
||||
modRef.componentFactoryResolver.resolveComponentFactory(App).create(Injector.NULL);
|
||||
|
||||
expect(getDOM().hasAttribute(compRef.location.nativeElement, 'ng-version')).toBe(false);
|
||||
expect(compRef.location.nativeElement.hasAttribute('ng-version')).toBe(false);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
@ -122,7 +122,7 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
const div = cmp.debugElement.children[0];
|
||||
expect(div.injector.get(OnPrefixDir).onclick).toBe(value);
|
||||
expect(getDOM().getProperty(div.nativeElement, 'onclick')).not.toBe(value);
|
||||
expect(getDOM().hasAttribute(div.nativeElement, 'onclick')).toEqual(false);
|
||||
expect(div.nativeElement.hasAttribute('onclick')).toEqual(false);
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user