refactor(core): move server-only DomAdapter methods into ServerRenderer (#32408)

PR Close #32408
This commit is contained in:
Kara Erickson
2019-08-29 21:24:33 -07:00
committed by Miško Hevery
parent 1ed3531049
commit 970b58b13f
16 changed files with 61 additions and 123 deletions

View File

@ -1694,7 +1694,7 @@ function declareTests(config?: {useJit: boolean}) {
fixture.componentInstance.ctxProp = 'TITLE';
fixture.detectChanges();
const el = getDOM().querySelector(fixture.nativeElement, 'span');
const el = fixture.nativeElement.querySelector('span');
expect(el.title).toBeFalsy();
});
@ -1707,7 +1707,7 @@ function declareTests(config?: {useJit: boolean}) {
fixture.componentInstance.ctxProp = 'TITLE';
fixture.detectChanges();
const el = getDOM().querySelector(fixture.nativeElement, 'span');
const el = fixture.nativeElement.querySelector('span');
expect(getDOM().getProperty(el, 'title')).toEqual('TITLE');
});
});
@ -2685,16 +2685,12 @@ class ComponentWithoutView {
@Directive({selector: '[no-duplicate]'})
class DuplicateDir {
constructor(elRef: ElementRef) {
getDOM().setText(elRef.nativeElement, elRef.nativeElement.textContent + 'noduplicate');
}
constructor(elRef: ElementRef) { elRef.nativeElement.textContent += 'noduplicate'; }
}
@Directive({selector: '[no-duplicate]'})
class OtherDuplicateDir {
constructor(elRef: ElementRef) {
getDOM().setText(elRef.nativeElement, elRef.nativeElement.textContent + 'othernoduplicate');
}
constructor(elRef: ElementRef) { elRef.nativeElement.textContent += 'othernoduplicate'; }
}
@Directive({selector: 'directive-throwing-error'})

View File

@ -136,8 +136,9 @@ describe('projection', () => {
componentFactoryResolver.resolveComponentFactory(MultipleContentTagsComponent);
expect(componentFactory.ngContentSelectors).toEqual(['h1', '*']);
const nodeOne = getDOM().createTextNode('one');
const nodeTwo = getDOM().createTextNode('two');
const nodeOne = getDOM().getDefaultDocument().createTextNode('one');
const nodeTwo = getDOM().getDefaultDocument().createTextNode('two');
const component = componentFactory.create(injector, [[nodeOne], [nodeTwo]]);
expect(component.location.nativeElement).toHaveText('(one, two)');
});
@ -175,9 +176,9 @@ describe('projection', () => {
componentFactoryResolver.resolveComponentFactory(MultipleContentTagsComponent);
expect(componentFactory.ngContentSelectors).toEqual(['h1', '*', 'h2']);
const nodeOne = getDOM().createTextNode('one');
const nodeTwo = getDOM().createTextNode('two');
const nodeThree = getDOM().createTextNode('three');
const nodeOne = getDOM().getDefaultDocument().createTextNode('one');
const nodeTwo = getDOM().getDefaultDocument().createTextNode('two');
const nodeThree = getDOM().getDefaultDocument().createTextNode('three');
const component = componentFactory.create(injector, [[nodeOne], [nodeTwo], [nodeThree]]);
component.changeDetectorRef.detectChanges();
expect(component.location.nativeElement.textContent.trim()).toBe('1one 2two 3three');