refactor(core): move Meta methods that only have one version from DomAdapter (#32408)

PR Close #32408
This commit is contained in:
Kara Erickson
2019-08-30 12:52:48 -07:00
committed by Miško Hevery
parent 1a7c79746d
commit 89434e09c2
28 changed files with 88 additions and 111 deletions
@@ -78,7 +78,7 @@ export class DominoAdapter extends BrowserDomAdapter {
if (name === 'href') {
// Domino tries to resolve href-s which we do not want. Just return the
// attribute value.
return this.getAttribute(el, 'href');
return el.getAttribute('href');
} else if (name === 'innerText') {
// Domino does not support innerText. Just map it to textContent.
return el.textContent;
@@ -88,7 +88,7 @@ class DefaultServerRenderer2 implements Renderer2 {
return doc.createTextNode(value);
}
appendChild(parent: any, newChild: any): void { getDOM().appendChild(parent, newChild); }
appendChild(parent: any, newChild: any): void { parent.appendChild(newChild); }
insertBefore(parent: any, newChild: any, refChild: any): void {
if (parent) {
@@ -126,7 +126,7 @@ class DefaultServerRenderer2 implements Renderer2 {
if (namespace) {
el.setAttributeNS(NAMESPACE_URIS[namespace], namespace + ':' + name, value);
} else {
getDOM().setAttribute(el, name, value);
el.setAttribute(name, value);
}
}
+3 -3
View File
@@ -18,7 +18,7 @@ export class ServerStylesHost extends SharedStylesHost {
@Inject(DOCUMENT) private doc: any,
@Optional() @Inject(ɵTRANSITION_ID) private transitionId: string) {
super();
this.head = getDOM().getElementsByTagName(doc, 'head')[0];
this.head = doc.getElementsByTagName('head')[0];
}
private _addStyle(style: string): void {
@@ -26,9 +26,9 @@ export class ServerStylesHost extends SharedStylesHost {
const el = adapter.createElement('style');
el.textContent = style;
if (!!this.transitionId) {
adapter.setAttribute(el, 'ng-transition', this.transitionId);
el.setAttribute('ng-transition', this.transitionId);
}
adapter.appendChild(this.head, el);
this.head.appendChild(el);
}
onStylesAdded(additions: Set<string>) { additions.forEach(style => this._addStyle(style)); }
@@ -473,11 +473,11 @@ class HiddenModule {
}]);
platform.bootstrapModule(ExampleStylesModule).then(ref => {
const doc = ref.injector.get(DOCUMENT);
const head = getDOM().getElementsByTagName(doc, 'head')[0];
const head = doc.getElementsByTagName('head')[0];
const styles: any[] = head.children as any;
expect(styles.length).toBe(1);
expect(styles[0].textContent).toContain('color: red');
expect(getDOM().getAttribute(styles[0], 'ng-transition')).toBe('example-styles');
expect(styles[0].getAttribute('ng-transition')).toBe('example-styles');
});
}));
@@ -487,7 +487,7 @@ class HiddenModule {
platform.bootstrapModule(ImageExampleModule).then(ref => {
const appRef: ApplicationRef = ref.injector.get(ApplicationRef);
const app = appRef.components[0].location.nativeElement;
const img = getDOM().getElementsByTagName(app, 'img')[0] as any;
const img = app.getElementsByTagName('img')[0] as any;
expect(img.attributes['src'].value).toEqual('link');
});
}));