diff --git a/aio/scripts/_payload-limits.json b/aio/scripts/_payload-limits.json
index 6de9bf06e5835..96a8d04ca0dc3 100755
--- a/aio/scripts/_payload-limits.json
+++ b/aio/scripts/_payload-limits.json
@@ -16,8 +16,8 @@
"uncompressed": {
"runtime-es5": 3042,
"runtime-es2015": 3048,
- "main-es5": 499085,
- "main-es2015": 438296,
+ "main-es5": 493330,
+ "main-es2015": 435296,
"polyfills-es5": 131024,
"polyfills-es2015": 52433
}
@@ -28,7 +28,7 @@
"uncompressed": {
"runtime-es5": 2932,
"runtime-es2015": 2938,
- "main-es5": 552068,
+ "main-es5": 550854,
"main-es2015": 493320,
"polyfills-es5": 131024,
"polyfills-es2015": 52433
diff --git a/integration/_payload-limits.json b/integration/_payload-limits.json
index 55599085e4c9e..c0e4539526ad9 100644
--- a/integration/_payload-limits.json
+++ b/integration/_payload-limits.json
@@ -3,7 +3,7 @@
"master": {
"uncompressed": {
"runtime": 1497,
- "main": 158490,
+ "main": 157490,
"polyfills": 45399
}
}
@@ -21,7 +21,7 @@
"master": {
"uncompressed": {
"runtime": 1440,
- "main": 125882,
+ "main": 123904,
"polyfills": 45340
}
}
diff --git a/packages/common/src/dom_adapter.ts b/packages/common/src/dom_adapter.ts
index 8dc07e158f4ab..ea8ba85defbf7 100644
--- a/packages/common/src/dom_adapter.ts
+++ b/packages/common/src/dom_adapter.ts
@@ -40,13 +40,8 @@ export abstract class DomAdapter {
abstract logGroupEnd(): any;
// Used by Meta
- abstract querySelectorAll(el: any, selector: string): any[];
abstract remove(el: any): Node;
- abstract getAttribute(element: any, attribute: string): string|null;
- abstract appendChild(el: any, node: any): any;
abstract createElement(tagName: any, doc?: any): HTMLElement;
- abstract setAttribute(element: any, name: string, value: string): any;
- abstract getElementsByTagName(element: any, name: string): HTMLElement[];
abstract createHtmlDocument(): HTMLDocument;
abstract getDefaultDocument(): Document;
diff --git a/packages/compiler/test/selector/selector_spec.ts b/packages/compiler/test/selector/selector_spec.ts
index a81e88fb0cdd9..01fb5a891313d 100644
--- a/packages/compiler/test/selector/selector_spec.ts
+++ b/packages/compiler/test/selector/selector_spec.ts
@@ -128,7 +128,7 @@ import {el} from '@angular/platform-browser/testing/src/browser_util';
const elementSelector = new CssSelector();
const element = el('
');
- const empty = getDOM().getAttribute(element, 'attr') !;
+ const empty = element.getAttribute('attr') !;
elementSelector.addAttribute('some-decor', empty);
matcher.match(elementSelector, selectableCollector);
expect(matched).toEqual([s1[0], 1]);
diff --git a/packages/core/test/application_ref_spec.ts b/packages/core/test/application_ref_spec.ts
index e44face1e72a3..1575b5b2026dc 100644
--- a/packages/core/test/application_ref_spec.ts
+++ b/packages/core/test/application_ref_spec.ts
@@ -35,11 +35,11 @@ class SomeComponent {
const doc = TestBed.get(DOCUMENT);
const rootEl =
getContent(createTemplate(`<${selector}>${selector}>`)).firstChild;
- const oldRoots = getDOM().querySelectorAll(doc, selector);
+ const oldRoots = doc.querySelectorAll(selector);
for (let i = 0; i < oldRoots.length; i++) {
getDOM().remove(oldRoots[i]);
}
- getDOM().appendChild(doc.body, rootEl);
+ doc.body.appendChild(rootEl);
}
type CreateModuleOptions =
diff --git a/packages/core/test/debug/debug_node_spec.ts b/packages/core/test/debug/debug_node_spec.ts
index 78cec8b42d446..ea5eba385e45c 100644
--- a/packages/core/test/debug/debug_node_spec.ts
+++ b/packages/core/test/debug/debug_node_spec.ts
@@ -883,7 +883,7 @@ class TestCmptWithPropBindings {
// Move the content element outside the component
// so that it can't be reached via querySelector.
- getDOM().appendChild(parent, content);
+ parent.appendChild(content);
expect(fixture.debugElement.query(By.css('.content'))).toBeTruthy();
diff --git a/packages/core/test/dom/dom_adapter_spec.ts b/packages/core/test/dom/dom_adapter_spec.ts
index 0493c10ee65ae..fc4c540e3a791 100644
--- a/packages/core/test/dom/dom_adapter_spec.ts
+++ b/packages/core/test/dom/dom_adapter_spec.ts
@@ -21,13 +21,13 @@ import {isTextNode} from '@angular/platform-browser/testing/src/browser_util';
const t = getDOM().getDefaultDocument().createTextNode('hello');
expect(isTextNode(t)).toBe(true);
const d = getDOM().createElement('div');
- getDOM().appendChild(d, t);
+ d.appendChild(t);
expect(d.innerHTML).toEqual('hello');
});
it('should set className via the class attribute', () => {
const d = getDOM().createElement('div');
- getDOM().setAttribute(d, 'class', 'class1');
+ d.setAttribute('class', 'class1');
expect(d.className).toEqual('class1');
});
@@ -45,9 +45,9 @@ import {isTextNode} from '@angular/platform-browser/testing/src/browser_util';
it('should return the value of the base element', () => {
const baseEl = getDOM().createElement('base');
- getDOM().setAttribute(baseEl, 'href', '/drop/bass/connon/');
+ baseEl.setAttribute('href', '/drop/bass/connon/');
const headEl = defaultDoc.head;
- getDOM().appendChild(headEl, baseEl);
+ headEl.appendChild(baseEl);
const baseHref = getDOM().getBaseHref(defaultDoc);
headEl.removeChild(baseEl);
@@ -58,9 +58,9 @@ import {isTextNode} from '@angular/platform-browser/testing/src/browser_util';
it('should return a relative url', () => {
const baseEl = getDOM().createElement('base');
- getDOM().setAttribute(baseEl, 'href', 'base');
+ baseEl.setAttribute('href', 'base');
const headEl = defaultDoc.head;
- getDOM().appendChild(headEl, baseEl);
+ headEl.appendChild(baseEl);
const baseHref = getDOM().getBaseHref(defaultDoc) !;
headEl.removeChild(baseEl);
diff --git a/packages/core/test/linker/integration_spec.ts b/packages/core/test/linker/integration_spec.ts
index 999a4cd02598f..54a461a742113 100644
--- a/packages/core/test/linker/integration_spec.ts
+++ b/packages/core/test/linker/integration_spec.ts
@@ -114,12 +114,12 @@ function declareTests(config?: {useJit: boolean}) {
fixture.componentInstance.ctxProp = 'Initial aria label';
fixture.detectChanges();
- expect(getDOM().getAttribute(fixture.debugElement.children[0].nativeElement, 'aria-label'))
+ expect(fixture.debugElement.children[0].nativeElement.getAttribute('aria-label'))
.toEqual('Initial aria label');
fixture.componentInstance.ctxProp = 'Changed aria label';
fixture.detectChanges();
- expect(getDOM().getAttribute(fixture.debugElement.children[0].nativeElement, 'aria-label'))
+ expect(fixture.debugElement.children[0].nativeElement.getAttribute('aria-label'))
.toEqual('Changed aria label');
});
@@ -131,8 +131,7 @@ function declareTests(config?: {useJit: boolean}) {
fixture.componentInstance.ctxProp = 'bar';
fixture.detectChanges();
- expect(getDOM().getAttribute(fixture.debugElement.children[0].nativeElement, 'foo'))
- .toEqual('bar');
+ expect(fixture.debugElement.children[0].nativeElement.getAttribute('foo')).toEqual('bar');
fixture.componentInstance.ctxProp = null !;
fixture.detectChanges();
@@ -887,7 +886,7 @@ function declareTests(config?: {useJit: boolean}) {
fixture.detectChanges();
- expect(getDOM().getAttribute(fixture.debugElement.nativeElement, 'role')).toEqual('button');
+ expect(fixture.debugElement.nativeElement.getAttribute('role')).toEqual('button');
});
it('should support updating host element via hostAttributes on host elements', () => {
@@ -898,7 +897,7 @@ function declareTests(config?: {useJit: boolean}) {
fixture.detectChanges();
- expect(getDOM().getAttribute(fixture.debugElement.children[0].nativeElement, 'role'))
+ expect(fixture.debugElement.children[0].nativeElement.getAttribute('role'))
.toEqual('button');
});
@@ -1404,7 +1403,7 @@ function declareTests(config?: {useJit: boolean}) {
TestBed.overrideComponent(MyComp, {set: {template}});
const fixture = TestBed.createComponent(MyComp);
- expect(getDOM().querySelectorAll(fixture.nativeElement, 'script').length).toEqual(0);
+ expect(fixture.nativeElement.querySelectorAll('script').length).toEqual(0);
});
it('should throw when using directives without selector in NgModule declarations', () => {
@@ -2139,7 +2138,7 @@ class SimpleImperativeViewComponent {
constructor(self: ElementRef) {
const hostElement = self.nativeElement;
- getDOM().appendChild(hostElement, el('hello imp view'));
+ hostElement.appendChild(el('hello imp view'));
}
}
@@ -2663,7 +2662,7 @@ class SomeImperativeViewport {
this.view = this.vc.createEmbeddedView(this.templateRef);
const nodes = this.view.rootNodes;
for (let i = 0; i < nodes.length; i++) {
- getDOM().appendChild(this.anchor, nodes[i]);
+ this.anchor.appendChild(nodes[i]);
}
}
}
diff --git a/packages/core/test/linker/projection_integration_spec.ts b/packages/core/test/linker/projection_integration_spec.ts
index 495f5356e0482..30b2df687908f 100644
--- a/packages/core/test/linker/projection_integration_spec.ts
+++ b/packages/core/test/linker/projection_integration_spec.ts
@@ -524,8 +524,8 @@ describe('projection', () => {
const mainEl = main.nativeElement;
const div1 = mainEl.firstChild;
const div2 = getDOM().createElement('div');
- getDOM().setAttribute(div2, 'class', 'redStyle');
- getDOM().appendChild(mainEl, div2);
+ div2.setAttribute('class', 'redStyle');
+ mainEl.appendChild(div2);
expect(getComputedStyle(div1).color).toEqual('rgb(255, 0, 0)');
expect(getComputedStyle(div2).color).toEqual('rgb(255, 0, 0)');
});
@@ -544,7 +544,7 @@ describe('projection', () => {
const mainEl = main.nativeElement;
const div1 = mainEl.firstChild;
const div2 = getDOM().createElement('div');
- getDOM().appendChild(mainEl, div2);
+ mainEl.appendChild(div2);
expect(getComputedStyle(div1).color).toEqual('rgb(255, 0, 0)');
expect(getComputedStyle(div2).color).toEqual('rgb(0, 0, 0)');
});
diff --git a/packages/core/test/linker/regression_integration_spec.ts b/packages/core/test/linker/regression_integration_spec.ts
index 72b0087a92d33..4666970a22424 100644
--- a/packages/core/test/linker/regression_integration_spec.ts
+++ b/packages/core/test/linker/regression_integration_spec.ts
@@ -438,7 +438,7 @@ function declareTestsUsingBootstrap() {
beforeEach(inject([DOCUMENT], (doc: any) => {
destroyPlatform();
const el = getDOM().createElement(COMP_SELECTOR, doc);
- getDOM().appendChild(doc.body, el);
+ doc.body.appendChild(el);
logger = new MockConsole();
errorHandler = new ErrorHandler();
diff --git a/packages/core/test/linker/security_integration_spec.ts b/packages/core/test/linker/security_integration_spec.ts
index ff3cc0a3ff3c8..36065423b13bd 100644
--- a/packages/core/test/linker/security_integration_spec.ts
+++ b/packages/core/test/linker/security_integration_spec.ts
@@ -177,13 +177,12 @@ function declareTests(config?: {useJit: boolean}) {
fixture.detectChanges();
// In the browser, reading href returns an absolute URL. On the server side,
// it just echoes back the property.
- let value =
- isAttribute ? getDOM().getAttribute(e, 'href') : getDOM().getProperty(e, 'href');
+ let value = isAttribute ? e.getAttribute('href') : getDOM().getProperty(e, 'href');
expect(value).toMatch(/.*\/?hello$/);
ci.ctxProp = 'javascript:alert(1)';
fixture.detectChanges();
- value = isAttribute ? getDOM().getAttribute(e, 'href') : getDOM().getProperty(e, 'href');
+ value = isAttribute ? e.getAttribute('href') : getDOM().getProperty(e, 'href');
expect(value).toEqual('unsafe:javascript:alert(1)');
}
diff --git a/packages/core/test/view/element_spec.ts b/packages/core/test/view/element_spec.ts
index 94789ff071c47..11e03b0f2b3a9 100644
--- a/packages/core/test/view/element_spec.ts
+++ b/packages/core/test/view/element_spec.ts
@@ -58,7 +58,7 @@ const removeEventListener = '__zone_symbol__removeEventListener' as 'removeEvent
elementDef(0, NodeFlags.None, null, null, 0, 'div', [['title', 'a']]),
])).rootNodes;
expect(rootNodes.length).toBe(1);
- expect(getDOM().getAttribute(rootNodes[0], 'title')).toBe('a');
+ expect(rootNodes[0].getAttribute('title')).toBe('a');
});
it('should add debug information to the renderer', () => {
@@ -114,8 +114,8 @@ const removeEventListener = '__zone_symbol__removeEventListener' as 'removeEvent
Services.checkAndUpdateView(view);
const el = rootNodes[0];
- expect(getDOM().getAttribute(el, 'a1')).toBe('v1');
- expect(getDOM().getAttribute(el, 'a2')).toBe('v2');
+ expect(el.getAttribute('a1')).toBe('v1');
+ expect(el.getAttribute('a2')).toBe('v2');
});
});
});
diff --git a/packages/core/test/view/embedded_view_spec.ts b/packages/core/test/view/embedded_view_spec.ts
index 9ae9ff8ea6ad3..3b9cbcd2f4fef 100644
--- a/packages/core/test/view/embedded_view_spec.ts
+++ b/packages/core/test/view/embedded_view_spec.ts
@@ -55,8 +55,8 @@ import {compViewDef, compViewDefFactory, createAndGetRootNodes, createEmbeddedVi
// 2 anchors + 2 elements
const rootChildren = rootNodes[0].childNodes;
expect(rootChildren.length).toBe(4);
- expect(getDOM().getAttribute(rootChildren[1], 'name')).toBe('child0');
- expect(getDOM().getAttribute(rootChildren[2], 'name')).toBe('child1');
+ expect(rootChildren[1].getAttribute('name')).toBe('child0');
+ expect(rootChildren[2].getAttribute('name')).toBe('child1');
rf.begin !();
detachEmbeddedView(viewContainerData, 1);
@@ -90,8 +90,8 @@ import {compViewDef, compViewDefFactory, createAndGetRootNodes, createEmbeddedVi
// 2 anchors + 2 elements
const rootChildren = rootNodes[0].childNodes;
expect(rootChildren.length).toBe(4);
- expect(getDOM().getAttribute(rootChildren[1], 'name')).toBe('child1');
- expect(getDOM().getAttribute(rootChildren[2], 'name')).toBe('child0');
+ expect(rootChildren[1].getAttribute('name')).toBe('child1');
+ expect(rootChildren[2].getAttribute('name')).toBe('child0');
});
it('should include embedded views in root nodes', () => {
@@ -107,8 +107,8 @@ import {compViewDef, compViewDefFactory, createAndGetRootNodes, createEmbeddedVi
const rootNodes = rootRenderNodes(parentView);
expect(rootNodes.length).toBe(3);
- expect(getDOM().getAttribute(rootNodes[1], 'name')).toBe('child0');
- expect(getDOM().getAttribute(rootNodes[2], 'name')).toBe('after');
+ expect(rootNodes[1].getAttribute('name')).toBe('child0');
+ expect(rootNodes[2].getAttribute('name')).toBe('after');
});
it('should dirty check embedded views', () => {
diff --git a/packages/core/test/view/provider_spec.ts b/packages/core/test/view/provider_spec.ts
index 01a67c5866ada..fdc4e1d76ab8f 100644
--- a/packages/core/test/view/provider_spec.ts
+++ b/packages/core/test/view/provider_spec.ts
@@ -340,7 +340,7 @@ import {ARG_TYPE_VALUES, checkNodeInlineOrDynamic, createRootView, createAndGetR
expect(instance.b).toBe('v2');
const el = rootNodes[0];
- expect(getDOM().getAttribute(el, 'ng-reflect-a')).toBe('v1');
+ expect(el.getAttribute('ng-reflect-a')).toBe('v1');
});
});
diff --git a/packages/platform-browser-dynamic/testing/src/dom_test_component_renderer.ts b/packages/platform-browser-dynamic/testing/src/dom_test_component_renderer.ts
index 473f7c47b6ac7..46e3ea96abf2f 100644
--- a/packages/platform-browser-dynamic/testing/src/dom_test_component_renderer.ts
+++ b/packages/platform-browser-dynamic/testing/src/dom_test_component_renderer.ts
@@ -23,11 +23,11 @@ export class DOMTestComponentRenderer extends TestComponentRenderer {
const rootEl = getContent(template).firstChild;
// TODO(juliemr): can/should this be optional?
- const oldRoots = getDOM().querySelectorAll(this._doc, '[id^=root]');
+ const oldRoots = this._doc.querySelectorAll('[id^=root]');
for (let i = 0; i < oldRoots.length; i++) {
getDOM().remove(oldRoots[i]);
}
- getDOM().appendChild(this._doc.body, rootEl);
+ this._doc.body.appendChild(rootEl);
}
}
diff --git a/packages/platform-browser/src/browser/browser_adapter.ts b/packages/platform-browser/src/browser/browser_adapter.ts
index 54a31a4609280..ced19976b57fd 100644
--- a/packages/platform-browser/src/browser/browser_adapter.ts
+++ b/packages/platform-browser/src/browser/browser_adapter.ts
@@ -50,7 +50,6 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
}
}
- querySelectorAll(el: any, selector: string): any[] { return el.querySelectorAll(selector); }
onAndCancel(el: Node, evt: any, listener: any): Function {
el.addEventListener(evt, listener, false);
// Needed to follow Dart's subscription semantic, until fix of
@@ -58,7 +57,6 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
return () => { el.removeEventListener(evt, listener, false); };
}
dispatchEvent(el: Node, evt: any) { el.dispatchEvent(evt); }
- appendChild(el: Node, node: Node) { el.appendChild(node); }
remove(node: Node): Node {
if (node.parentNode) {
node.parentNode.removeChild(node);
@@ -70,15 +68,6 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
doc = doc || this.getDefaultDocument();
return doc.createElement(tagName);
}
- getElementsByTagName(element: any, name: string): HTMLElement[] {
- return element.getElementsByTagName(name);
- }
-
- getAttribute(element: Element, attribute: string): string|null {
- return element.getAttribute(attribute);
- }
- setAttribute(element: Element, name: string, value: string) { element.setAttribute(name, value); }
-
createHtmlDocument(): HTMLDocument {
return document.implementation.createHTMLDocument('fakeTitle');
}
diff --git a/packages/platform-browser/src/browser/meta.ts b/packages/platform-browser/src/browser/meta.ts
index 8b10675bb7792..0962e4656ce35 100644
--- a/packages/platform-browser/src/browser/meta.ts
+++ b/packages/platform-browser/src/browser/meta.ts
@@ -65,7 +65,7 @@ export class Meta {
getTags(attrSelector: string): HTMLMetaElement[] {
if (!attrSelector) return [];
- const list /*NodeList*/ = this._dom.querySelectorAll(this._doc, `meta[${attrSelector}]`);
+ const list /*NodeList*/ = this._doc.querySelectorAll(`meta[${attrSelector}]`);
return list ? [].slice.call(list) : [];
}
@@ -99,13 +99,13 @@ export class Meta {
}
const element: HTMLMetaElement = this._dom.createElement('meta') as HTMLMetaElement;
this._setMetaElementAttributes(meta, element);
- const head = this._dom.getElementsByTagName(this._doc, 'head')[0];
- this._dom.appendChild(head, element);
+ const head = this._doc.getElementsByTagName('head')[0];
+ head.appendChild(element);
return element;
}
private _setMetaElementAttributes(tag: MetaDefinition, el: HTMLMetaElement): HTMLMetaElement {
- Object.keys(tag).forEach((prop: string) => this._dom.setAttribute(el, prop, tag[prop]));
+ Object.keys(tag).forEach((prop: string) => el.setAttribute(prop, tag[prop]));
return el;
}
@@ -115,6 +115,6 @@ export class Meta {
}
private _containsAttributes(tag: MetaDefinition, elem: HTMLMetaElement): boolean {
- return Object.keys(tag).every((key: string) => this._dom.getAttribute(elem, key) === tag[key]);
+ return Object.keys(tag).every((key: string) => elem.getAttribute(key) === tag[key]);
}
}
diff --git a/packages/platform-browser/src/browser/server-transition.ts b/packages/platform-browser/src/browser/server-transition.ts
index 1277df68fe45c..d3c33e670526e 100644
--- a/packages/platform-browser/src/browser/server-transition.ts
+++ b/packages/platform-browser/src/browser/server-transition.ts
@@ -23,7 +23,7 @@ export function appInitializerFactory(transitionId: string, document: any, injec
const dom = getDOM();
const styles: any[] =
Array.prototype.slice.apply(document.querySelectorAll(`style[ng-transition]`));
- styles.filter(el => dom.getAttribute(el, 'ng-transition') === transitionId)
+ styles.filter(el => el.getAttribute('ng-transition') === transitionId)
.forEach(el => dom.remove(el));
});
};
diff --git a/packages/platform-browser/test/browser/bootstrap_spec.ts b/packages/platform-browser/test/browser/bootstrap_spec.ts
index b1feb2aa423b4..0fbf42f4c6852 100644
--- a/packages/platform-browser/test/browser/bootstrap_spec.ts
+++ b/packages/platform-browser/test/browser/bootstrap_spec.ts
@@ -142,7 +142,7 @@ function bootstrap(
compilerConsole = new DummyConsole();
testProviders = [{provide: Console, useValue: compilerConsole}];
- const oldRoots = getDOM().querySelectorAll(doc, 'hello-app,hello-app-2,light-dom-el');
+ const oldRoots = doc.querySelectorAll('hello-app,hello-app-2,light-dom-el');
for (let i = 0; i < oldRoots.length; i++) {
getDOM().remove(oldRoots[i]);
}
@@ -150,9 +150,9 @@ function bootstrap(
el = getDOM().createElement('hello-app', doc);
el2 = getDOM().createElement('hello-app-2', doc);
lightDom = getDOM().createElement('light-dom-el', doc);
- getDOM().appendChild(doc.body, el);
- getDOM().appendChild(doc.body, el2);
- getDOM().appendChild(el, lightDom);
+ doc.body.appendChild(el);
+ doc.body.appendChild(el2);
+ el.appendChild(lightDom);
lightDom.textContent = 'loading';
}));
@@ -440,17 +440,17 @@ function bootstrap(
const platform = platformBrowserDynamic();
const document = platform.injector.get(DOCUMENT);
const style = dom.createElement('style', document);
- dom.setAttribute(style, 'ng-transition', 'my-app');
- dom.appendChild(document.head, style);
+ style.setAttribute('ng-transition', 'my-app');
+ document.head.appendChild(style);
const root = dom.createElement('root', document);
- dom.appendChild(document.body, root);
+ document.body.appendChild(root);
platform.bootstrapModule(TestModule).then(() => {
const styles: HTMLElement[] =
- Array.prototype.slice.apply(dom.getElementsByTagName(document, 'style') || []);
+ Array.prototype.slice.apply(document.getElementsByTagName('style') || []);
styles.forEach(
- style => { expect(dom.getAttribute(style, 'ng-transition')).not.toBe('my-app'); });
+ style => { expect(style.getAttribute('ng-transition')).not.toBe('my-app'); });
async.done();
});
}));
diff --git a/packages/platform-browser/test/browser/meta_spec.ts b/packages/platform-browser/test/browser/meta_spec.ts
index 3bea3d12a2771..3371ecf9ceede 100644
--- a/packages/platform-browser/test/browser/meta_spec.ts
+++ b/packages/platform-browser/test/browser/meta_spec.ts
@@ -22,9 +22,9 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
doc = getDOM().createHtmlDocument();
metaService = new Meta(doc);
defaultMeta = getDOM().createElement('meta', doc) as HTMLMetaElement;
- getDOM().setAttribute(defaultMeta, 'property', 'fb:app_id');
- getDOM().setAttribute(defaultMeta, 'content', '123456789');
- getDOM().appendChild(getDOM().getElementsByTagName(doc, 'head')[0], defaultMeta);
+ defaultMeta.setAttribute('property', 'fb:app_id');
+ defaultMeta.setAttribute('content', '123456789');
+ doc.getElementsByTagName('head')[0].appendChild(defaultMeta);
});
afterEach(() => getDOM().remove(defaultMeta));
@@ -32,7 +32,7 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
it('should return meta tag matching selector', () => {
const actual: HTMLMetaElement = metaService.getTag('property="fb:app_id"') !;
expect(actual).not.toBeNull();
- expect(getDOM().getAttribute(actual, 'content')).toEqual('123456789');
+ expect(actual.getAttribute('content')).toEqual('123456789');
});
it('should return all meta tags matching selector', () => {
@@ -41,8 +41,8 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
const actual: HTMLMetaElement[] = metaService.getTags('name=author');
expect(actual.length).toEqual(2);
- expect(getDOM().getAttribute(actual[0], 'content')).toEqual('page author');
- expect(getDOM().getAttribute(actual[1], 'content')).toEqual('another page author');
+ expect(actual[0].getAttribute('content')).toEqual('page author');
+ expect(actual[1].getAttribute('content')).toEqual('another page author');
// clean up
metaService.removeTagElement(tag1);
@@ -87,7 +87,7 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
const actual = metaService.getTag(selector);
expect(actual).not.toBeNull();
- expect(getDOM().getAttribute(actual, 'content')).toEqual('4321');
+ expect(actual !.getAttribute('content')).toEqual('4321');
});
it('should extract selector from the tag definition', () => {
@@ -96,7 +96,7 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
const actual = metaService.getTag(selector);
expect(actual).not.toBeNull();
- expect(getDOM().getAttribute(actual, 'content')).toEqual('666');
+ expect(actual !.getAttribute('content')).toEqual('666');
});
it('should create meta tag if it does not exist', () => {
@@ -106,7 +106,7 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
const actual = metaService.getTag(selector) !;
expect(actual).not.toBeNull();
- expect(getDOM().getAttribute(actual, 'content')).toEqual('Content Title');
+ expect(actual.getAttribute('content')).toEqual('Content Title');
// clean up
metaService.removeTagElement(actual);
@@ -120,7 +120,7 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
const actual = metaService.getTag(selector) !;
expect(actual).not.toBeNull();
- expect(getDOM().getAttribute(actual, 'content')).toEqual('Content Title');
+ expect(actual.getAttribute('content')).toEqual('Content Title');
// clean up
metaService.removeTagElement(actual);
diff --git a/packages/platform-browser/test/dom/events/event_manager_spec.ts b/packages/platform-browser/test/dom/events/event_manager_spec.ts
index 42f954d7709f1..dd8b6af096fa2 100644
--- a/packages/platform-browser/test/dom/events/event_manager_spec.ts
+++ b/packages/platform-browser/test/dom/events/event_manager_spec.ts
@@ -61,7 +61,7 @@ import {createMouseEvent, el} from '../../../testing/src/browser_util';
it('events are caught when fired from a child', () => {
const element = el('');
// Workaround for https://bugs.webkit.org/show_bug.cgi?id=122755
- getDOM().appendChild(doc.body, element);
+ doc.body.appendChild(element);
const child = element.firstChild as Element;
const dispatchedEvent = createMouseEvent('click');
@@ -76,7 +76,7 @@ import {createMouseEvent, el} from '../../../testing/src/browser_util';
it('should add and remove global event listeners', () => {
const element = el('');
- getDOM().appendChild(doc.body, element);
+ doc.body.appendChild(element);
const dispatchedEvent = createMouseEvent('click');
let receivedEvent: any /** TODO #9100 */ = null;
const handler = (e: any /** TODO #9100 */) => { receivedEvent = e; };
@@ -96,7 +96,7 @@ import {createMouseEvent, el} from '../../../testing/src/browser_util';
const Zone = (window as any)['Zone'];
const element = el('');
- getDOM().appendChild(doc.body, element);
+ doc.body.appendChild(element);
const dispatchedEvent = createMouseEvent('click');
let receivedEvent: any /** TODO #9100 */ = null;
let receivedZone: any = null;
@@ -122,7 +122,7 @@ import {createMouseEvent, el} from '../../../testing/src/browser_util';
const Zone = (window as any)['Zone'];
const element = el('');
- getDOM().appendChild(doc.body, element);
+ doc.body.appendChild(element);
const dispatchedEvent = createMouseEvent('click');
let receivedEvents: any[] /** TODO #9100 */ = [];
let receivedZones: any[] = [];
@@ -157,7 +157,7 @@ import {createMouseEvent, el} from '../../../testing/src/browser_util';
const Zone = (window as any)['Zone'];
const element = el('');
- getDOM().appendChild(doc.body, element);
+ doc.body.appendChild(element);
const dispatchedEvent = createMouseEvent('click');
let receivedEvents: any[] /** TODO #9100 */ = [];
let receivedZones: any[] = [];
@@ -193,7 +193,7 @@ import {createMouseEvent, el} from '../../../testing/src/browser_util';
const Zone = (window as any)['Zone'];
const element = el('');
- getDOM().appendChild(doc.body, element);
+ doc.body.appendChild(element);
const dispatchedEvent = createMouseEvent('click');
let receivedEvents: any[] /** TODO #9100 */ = [];
let receivedZones: any[] = [];
@@ -229,7 +229,7 @@ import {createMouseEvent, el} from '../../../testing/src/browser_util';
const Zone = (window as any)['Zone'];
const element = el('');
- getDOM().appendChild(doc.body, element);
+ doc.body.appendChild(element);
const dispatchedEvent = createMouseEvent('click');
let receivedEvents: any[] /** TODO #9100 */ = [];
let receivedZones: any[] = [];
@@ -260,7 +260,7 @@ import {createMouseEvent, el} from '../../../testing/src/browser_util';
const Zone = (window as any)['Zone'];
const element = el('');
- getDOM().appendChild(doc.body, element);
+ doc.body.appendChild(element);
const dispatchedEvent = createMouseEvent('click');
let receivedEvents: any[] /** TODO #9100 */ = [];
let receivedZones: any[] = [];
@@ -299,7 +299,7 @@ import {createMouseEvent, el} from '../../../testing/src/browser_util';
it('should run blockListedEvents handler outside of ngZone', () => {
const Zone = (window as any)['Zone'];
const element = el('');
- getDOM().appendChild(doc.body, element);
+ doc.body.appendChild(element);
const dispatchedEvent = createMouseEvent('scroll');
let receivedEvent: any /** TODO #9100 */ = null;
let receivedZone: any = null;
diff --git a/packages/platform-server/src/domino_adapter.ts b/packages/platform-server/src/domino_adapter.ts
index f1cac8a04774e..87370fd9fbfee 100644
--- a/packages/platform-server/src/domino_adapter.ts
+++ b/packages/platform-server/src/domino_adapter.ts
@@ -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;
diff --git a/packages/platform-server/src/server_renderer.ts b/packages/platform-server/src/server_renderer.ts
index e097642871135..7767196f52713 100644
--- a/packages/platform-server/src/server_renderer.ts
+++ b/packages/platform-server/src/server_renderer.ts
@@ -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);
}
}
diff --git a/packages/platform-server/src/styles_host.ts b/packages/platform-server/src/styles_host.ts
index 3dd3e7320c855..243125d784e7a 100644
--- a/packages/platform-server/src/styles_host.ts
+++ b/packages/platform-server/src/styles_host.ts
@@ -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) { additions.forEach(style => this._addStyle(style)); }
diff --git a/packages/platform-server/test/integration_spec.ts b/packages/platform-server/test/integration_spec.ts
index 31f488d25fb4b..62c0063e4f8a9 100644
--- a/packages/platform-server/test/integration_spec.ts
+++ b/packages/platform-server/test/integration_spec.ts
@@ -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');
});
}));
diff --git a/packages/platform-webworker/src/web_workers/worker/worker_adapter.ts b/packages/platform-webworker/src/web_workers/worker/worker_adapter.ts
index db2ea7b9b76fb..f5d549ae8bffb 100644
--- a/packages/platform-webworker/src/web_workers/worker/worker_adapter.ts
+++ b/packages/platform-webworker/src/web_workers/worker/worker_adapter.ts
@@ -44,15 +44,10 @@ export class WorkerDomAdapter extends DomAdapter {
getProperty(el: Element, name: string): any { throw 'not implemented'; }
- querySelectorAll(el: any, selector: string): any[] { throw 'not implemented'; }
onAndCancel(el: any, evt: any, listener: any): Function { throw 'not implemented'; }
dispatchEvent(el: any, evt: any) { throw 'not implemented'; }
- appendChild(el: any, node: any) { throw 'not implemented'; }
remove(el: any): Node { throw 'not implemented'; }
createElement(tagName: any, doc?: any): HTMLElement { throw 'not implemented'; }
- getElementsByTagName(element: any, name: string): HTMLElement[] { throw 'not implemented'; }
- getAttribute(element: any, attribute: string): string { throw 'not implemented'; }
- setAttribute(element: any, name: string, value: string) { throw 'not implemented'; }
createHtmlDocument(): HTMLDocument { throw 'not implemented'; }
getDefaultDocument(): Document { throw 'not implemented'; }
isElementNode(node: any): boolean { throw 'not implemented'; }
diff --git a/packages/platform-webworker/test/web_workers/worker/renderer_v2_integration_spec.ts b/packages/platform-webworker/test/web_workers/worker/renderer_v2_integration_spec.ts
index db9ab01ecbe92..c841bfb790bd6 100644
--- a/packages/platform-webworker/test/web_workers/worker/renderer_v2_integration_spec.ts
+++ b/packages/platform-webworker/test/web_workers/worker/renderer_v2_integration_spec.ts
@@ -121,7 +121,7 @@ let lastCreatedRenderer: Renderer2;
expect(el.style['width']).toEqual('');
lastCreatedRenderer.setAttribute(workerEl, 'someattr', 'someValue');
- expect(getDOM().getAttribute(el, 'someattr')).toEqual('someValue');
+ expect(el.getAttribute('someattr')).toEqual('someValue');
};
// root element
diff --git a/packages/router/test/bootstrap.spec.ts b/packages/router/test/bootstrap.spec.ts
index 8830999d7311a..a409fe90a26c1 100644
--- a/packages/router/test/bootstrap.spec.ts
+++ b/packages/router/test/bootstrap.spec.ts
@@ -42,15 +42,15 @@ describe('bootstrap', () => {
const el1 = getDOM().createElement('test-app', doc);
const el2 = getDOM().createElement('test-app2', doc);
- getDOM().appendChild(doc.body, el1);
- getDOM().appendChild(doc.body, el2);
+ doc.body.appendChild(el1);
+ doc.body.appendChild(el2);
log = [];
testProviders = [{provide: APP_BASE_HREF, useValue: ''}];
}));
afterEach(inject([DOCUMENT], (doc: any) => {
- const oldRoots = getDOM().querySelectorAll(doc, 'test-app,test-app2');
+ const oldRoots = doc.querySelectorAll('test-app,test-app2');
for (let i = 0; i < oldRoots.length; i++) {
getDOM().remove(oldRoots[i]);
}