refactor(core): move Meta methods that only have one version from DomAdapter (#32408)
PR Close #32408
This commit is contained in:
parent
1a7c79746d
commit
89434e09c2
|
@ -16,8 +16,8 @@
|
||||||
"uncompressed": {
|
"uncompressed": {
|
||||||
"runtime-es5": 3042,
|
"runtime-es5": 3042,
|
||||||
"runtime-es2015": 3048,
|
"runtime-es2015": 3048,
|
||||||
"main-es5": 499085,
|
"main-es5": 493330,
|
||||||
"main-es2015": 438296,
|
"main-es2015": 435296,
|
||||||
"polyfills-es5": 131024,
|
"polyfills-es5": 131024,
|
||||||
"polyfills-es2015": 52433
|
"polyfills-es2015": 52433
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,7 @@
|
||||||
"uncompressed": {
|
"uncompressed": {
|
||||||
"runtime-es5": 2932,
|
"runtime-es5": 2932,
|
||||||
"runtime-es2015": 2938,
|
"runtime-es2015": 2938,
|
||||||
"main-es5": 552068,
|
"main-es5": 550854,
|
||||||
"main-es2015": 493320,
|
"main-es2015": 493320,
|
||||||
"polyfills-es5": 131024,
|
"polyfills-es5": 131024,
|
||||||
"polyfills-es2015": 52433
|
"polyfills-es2015": 52433
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
"master": {
|
"master": {
|
||||||
"uncompressed": {
|
"uncompressed": {
|
||||||
"runtime": 1497,
|
"runtime": 1497,
|
||||||
"main": 158490,
|
"main": 157490,
|
||||||
"polyfills": 45399
|
"polyfills": 45399
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@
|
||||||
"master": {
|
"master": {
|
||||||
"uncompressed": {
|
"uncompressed": {
|
||||||
"runtime": 1440,
|
"runtime": 1440,
|
||||||
"main": 125882,
|
"main": 123904,
|
||||||
"polyfills": 45340
|
"polyfills": 45340
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -40,13 +40,8 @@ export abstract class DomAdapter {
|
||||||
abstract logGroupEnd(): any;
|
abstract logGroupEnd(): any;
|
||||||
|
|
||||||
// Used by Meta
|
// Used by Meta
|
||||||
abstract querySelectorAll(el: any, selector: string): any[];
|
|
||||||
abstract remove(el: any): Node;
|
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 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 createHtmlDocument(): HTMLDocument;
|
||||||
abstract getDefaultDocument(): Document;
|
abstract getDefaultDocument(): Document;
|
||||||
|
|
||||||
|
|
|
@ -128,7 +128,7 @@ import {el} from '@angular/platform-browser/testing/src/browser_util';
|
||||||
|
|
||||||
const elementSelector = new CssSelector();
|
const elementSelector = new CssSelector();
|
||||||
const element = el('<div attr></div>');
|
const element = el('<div attr></div>');
|
||||||
const empty = getDOM().getAttribute(element, 'attr') !;
|
const empty = element.getAttribute('attr') !;
|
||||||
elementSelector.addAttribute('some-decor', empty);
|
elementSelector.addAttribute('some-decor', empty);
|
||||||
matcher.match(elementSelector, selectableCollector);
|
matcher.match(elementSelector, selectableCollector);
|
||||||
expect(matched).toEqual([s1[0], 1]);
|
expect(matched).toEqual([s1[0], 1]);
|
||||||
|
|
|
@ -35,11 +35,11 @@ class SomeComponent {
|
||||||
const doc = TestBed.get(DOCUMENT);
|
const doc = TestBed.get(DOCUMENT);
|
||||||
const rootEl =
|
const rootEl =
|
||||||
<HTMLElement>getContent(createTemplate(`<${selector}></${selector}>`)).firstChild;
|
<HTMLElement>getContent(createTemplate(`<${selector}></${selector}>`)).firstChild;
|
||||||
const oldRoots = getDOM().querySelectorAll(doc, selector);
|
const oldRoots = doc.querySelectorAll(selector);
|
||||||
for (let i = 0; i < oldRoots.length; i++) {
|
for (let i = 0; i < oldRoots.length; i++) {
|
||||||
getDOM().remove(oldRoots[i]);
|
getDOM().remove(oldRoots[i]);
|
||||||
}
|
}
|
||||||
getDOM().appendChild(doc.body, rootEl);
|
doc.body.appendChild(rootEl);
|
||||||
}
|
}
|
||||||
|
|
||||||
type CreateModuleOptions =
|
type CreateModuleOptions =
|
||||||
|
|
|
@ -883,7 +883,7 @@ class TestCmptWithPropBindings {
|
||||||
|
|
||||||
// Move the content element outside the component
|
// Move the content element outside the component
|
||||||
// so that it can't be reached via querySelector.
|
// so that it can't be reached via querySelector.
|
||||||
getDOM().appendChild(parent, content);
|
parent.appendChild(content);
|
||||||
|
|
||||||
expect(fixture.debugElement.query(By.css('.content'))).toBeTruthy();
|
expect(fixture.debugElement.query(By.css('.content'))).toBeTruthy();
|
||||||
|
|
||||||
|
|
|
@ -21,13 +21,13 @@ import {isTextNode} from '@angular/platform-browser/testing/src/browser_util';
|
||||||
const t = getDOM().getDefaultDocument().createTextNode('hello');
|
const t = getDOM().getDefaultDocument().createTextNode('hello');
|
||||||
expect(isTextNode(t)).toBe(true);
|
expect(isTextNode(t)).toBe(true);
|
||||||
const d = getDOM().createElement('div');
|
const d = getDOM().createElement('div');
|
||||||
getDOM().appendChild(d, t);
|
d.appendChild(t);
|
||||||
expect(d.innerHTML).toEqual('hello');
|
expect(d.innerHTML).toEqual('hello');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set className via the class attribute', () => {
|
it('should set className via the class attribute', () => {
|
||||||
const d = getDOM().createElement('div');
|
const d = getDOM().createElement('div');
|
||||||
getDOM().setAttribute(d, 'class', 'class1');
|
d.setAttribute('class', 'class1');
|
||||||
expect(d.className).toEqual('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', () => {
|
it('should return the value of the base element', () => {
|
||||||
const baseEl = getDOM().createElement('base');
|
const baseEl = getDOM().createElement('base');
|
||||||
getDOM().setAttribute(baseEl, 'href', '/drop/bass/connon/');
|
baseEl.setAttribute('href', '/drop/bass/connon/');
|
||||||
const headEl = defaultDoc.head;
|
const headEl = defaultDoc.head;
|
||||||
getDOM().appendChild(headEl, baseEl);
|
headEl.appendChild(baseEl);
|
||||||
|
|
||||||
const baseHref = getDOM().getBaseHref(defaultDoc);
|
const baseHref = getDOM().getBaseHref(defaultDoc);
|
||||||
headEl.removeChild(baseEl);
|
headEl.removeChild(baseEl);
|
||||||
|
@ -58,9 +58,9 @@ import {isTextNode} from '@angular/platform-browser/testing/src/browser_util';
|
||||||
|
|
||||||
it('should return a relative url', () => {
|
it('should return a relative url', () => {
|
||||||
const baseEl = getDOM().createElement('base');
|
const baseEl = getDOM().createElement('base');
|
||||||
getDOM().setAttribute(baseEl, 'href', 'base');
|
baseEl.setAttribute('href', 'base');
|
||||||
const headEl = defaultDoc.head;
|
const headEl = defaultDoc.head;
|
||||||
getDOM().appendChild(headEl, baseEl);
|
headEl.appendChild(baseEl);
|
||||||
|
|
||||||
const baseHref = getDOM().getBaseHref(defaultDoc) !;
|
const baseHref = getDOM().getBaseHref(defaultDoc) !;
|
||||||
headEl.removeChild(baseEl);
|
headEl.removeChild(baseEl);
|
||||||
|
|
|
@ -114,12 +114,12 @@ function declareTests(config?: {useJit: boolean}) {
|
||||||
|
|
||||||
fixture.componentInstance.ctxProp = 'Initial aria label';
|
fixture.componentInstance.ctxProp = 'Initial aria label';
|
||||||
fixture.detectChanges();
|
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');
|
.toEqual('Initial aria label');
|
||||||
|
|
||||||
fixture.componentInstance.ctxProp = 'Changed aria label';
|
fixture.componentInstance.ctxProp = 'Changed aria label';
|
||||||
fixture.detectChanges();
|
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');
|
.toEqual('Changed aria label');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -131,8 +131,7 @@ function declareTests(config?: {useJit: boolean}) {
|
||||||
|
|
||||||
fixture.componentInstance.ctxProp = 'bar';
|
fixture.componentInstance.ctxProp = 'bar';
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
expect(getDOM().getAttribute(fixture.debugElement.children[0].nativeElement, 'foo'))
|
expect(fixture.debugElement.children[0].nativeElement.getAttribute('foo')).toEqual('bar');
|
||||||
.toEqual('bar');
|
|
||||||
|
|
||||||
fixture.componentInstance.ctxProp = null !;
|
fixture.componentInstance.ctxProp = null !;
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
@ -887,7 +886,7 @@ function declareTests(config?: {useJit: boolean}) {
|
||||||
|
|
||||||
fixture.detectChanges();
|
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', () => {
|
it('should support updating host element via hostAttributes on host elements', () => {
|
||||||
|
@ -898,7 +897,7 @@ function declareTests(config?: {useJit: boolean}) {
|
||||||
|
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
|
|
||||||
expect(getDOM().getAttribute(fixture.debugElement.children[0].nativeElement, 'role'))
|
expect(fixture.debugElement.children[0].nativeElement.getAttribute('role'))
|
||||||
.toEqual('button');
|
.toEqual('button');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -1404,7 +1403,7 @@ function declareTests(config?: {useJit: boolean}) {
|
||||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||||
const fixture = TestBed.createComponent(MyComp);
|
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', () => {
|
it('should throw when using directives without selector in NgModule declarations', () => {
|
||||||
|
@ -2139,7 +2138,7 @@ class SimpleImperativeViewComponent {
|
||||||
|
|
||||||
constructor(self: ElementRef) {
|
constructor(self: ElementRef) {
|
||||||
const hostElement = self.nativeElement;
|
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);
|
this.view = this.vc.createEmbeddedView(this.templateRef);
|
||||||
const nodes = this.view.rootNodes;
|
const nodes = this.view.rootNodes;
|
||||||
for (let i = 0; i < nodes.length; i++) {
|
for (let i = 0; i < nodes.length; i++) {
|
||||||
getDOM().appendChild(this.anchor, nodes[i]);
|
this.anchor.appendChild(nodes[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -524,8 +524,8 @@ describe('projection', () => {
|
||||||
const mainEl = main.nativeElement;
|
const mainEl = main.nativeElement;
|
||||||
const div1 = mainEl.firstChild;
|
const div1 = mainEl.firstChild;
|
||||||
const div2 = getDOM().createElement('div');
|
const div2 = getDOM().createElement('div');
|
||||||
getDOM().setAttribute(div2, 'class', 'redStyle');
|
div2.setAttribute('class', 'redStyle');
|
||||||
getDOM().appendChild(mainEl, div2);
|
mainEl.appendChild(div2);
|
||||||
expect(getComputedStyle(div1).color).toEqual('rgb(255, 0, 0)');
|
expect(getComputedStyle(div1).color).toEqual('rgb(255, 0, 0)');
|
||||||
expect(getComputedStyle(div2).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 mainEl = main.nativeElement;
|
||||||
const div1 = mainEl.firstChild;
|
const div1 = mainEl.firstChild;
|
||||||
const div2 = getDOM().createElement('div');
|
const div2 = getDOM().createElement('div');
|
||||||
getDOM().appendChild(mainEl, div2);
|
mainEl.appendChild(div2);
|
||||||
expect(getComputedStyle(div1).color).toEqual('rgb(255, 0, 0)');
|
expect(getComputedStyle(div1).color).toEqual('rgb(255, 0, 0)');
|
||||||
expect(getComputedStyle(div2).color).toEqual('rgb(0, 0, 0)');
|
expect(getComputedStyle(div2).color).toEqual('rgb(0, 0, 0)');
|
||||||
});
|
});
|
||||||
|
|
|
@ -438,7 +438,7 @@ function declareTestsUsingBootstrap() {
|
||||||
beforeEach(inject([DOCUMENT], (doc: any) => {
|
beforeEach(inject([DOCUMENT], (doc: any) => {
|
||||||
destroyPlatform();
|
destroyPlatform();
|
||||||
const el = getDOM().createElement(COMP_SELECTOR, doc);
|
const el = getDOM().createElement(COMP_SELECTOR, doc);
|
||||||
getDOM().appendChild(doc.body, el);
|
doc.body.appendChild(el);
|
||||||
|
|
||||||
logger = new MockConsole();
|
logger = new MockConsole();
|
||||||
errorHandler = new ErrorHandler();
|
errorHandler = new ErrorHandler();
|
||||||
|
|
|
@ -177,13 +177,12 @@ function declareTests(config?: {useJit: boolean}) {
|
||||||
fixture.detectChanges();
|
fixture.detectChanges();
|
||||||
// In the browser, reading href returns an absolute URL. On the server side,
|
// In the browser, reading href returns an absolute URL. On the server side,
|
||||||
// it just echoes back the property.
|
// it just echoes back the property.
|
||||||
let value =
|
let value = isAttribute ? e.getAttribute('href') : getDOM().getProperty(e, 'href');
|
||||||
isAttribute ? getDOM().getAttribute(e, 'href') : getDOM().getProperty(e, 'href');
|
|
||||||
expect(value).toMatch(/.*\/?hello$/);
|
expect(value).toMatch(/.*\/?hello$/);
|
||||||
|
|
||||||
ci.ctxProp = 'javascript:alert(1)';
|
ci.ctxProp = 'javascript:alert(1)';
|
||||||
fixture.detectChanges();
|
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)');
|
expect(value).toEqual('unsafe:javascript:alert(1)');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,7 @@ const removeEventListener = '__zone_symbol__removeEventListener' as 'removeEvent
|
||||||
elementDef(0, NodeFlags.None, null, null, 0, 'div', [['title', 'a']]),
|
elementDef(0, NodeFlags.None, null, null, 0, 'div', [['title', 'a']]),
|
||||||
])).rootNodes;
|
])).rootNodes;
|
||||||
expect(rootNodes.length).toBe(1);
|
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', () => {
|
it('should add debug information to the renderer', () => {
|
||||||
|
@ -114,8 +114,8 @@ const removeEventListener = '__zone_symbol__removeEventListener' as 'removeEvent
|
||||||
Services.checkAndUpdateView(view);
|
Services.checkAndUpdateView(view);
|
||||||
|
|
||||||
const el = rootNodes[0];
|
const el = rootNodes[0];
|
||||||
expect(getDOM().getAttribute(el, 'a1')).toBe('v1');
|
expect(el.getAttribute('a1')).toBe('v1');
|
||||||
expect(getDOM().getAttribute(el, 'a2')).toBe('v2');
|
expect(el.getAttribute('a2')).toBe('v2');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -55,8 +55,8 @@ import {compViewDef, compViewDefFactory, createAndGetRootNodes, createEmbeddedVi
|
||||||
// 2 anchors + 2 elements
|
// 2 anchors + 2 elements
|
||||||
const rootChildren = rootNodes[0].childNodes;
|
const rootChildren = rootNodes[0].childNodes;
|
||||||
expect(rootChildren.length).toBe(4);
|
expect(rootChildren.length).toBe(4);
|
||||||
expect(getDOM().getAttribute(rootChildren[1], 'name')).toBe('child0');
|
expect(rootChildren[1].getAttribute('name')).toBe('child0');
|
||||||
expect(getDOM().getAttribute(rootChildren[2], 'name')).toBe('child1');
|
expect(rootChildren[2].getAttribute('name')).toBe('child1');
|
||||||
|
|
||||||
rf.begin !();
|
rf.begin !();
|
||||||
detachEmbeddedView(viewContainerData, 1);
|
detachEmbeddedView(viewContainerData, 1);
|
||||||
|
@ -90,8 +90,8 @@ import {compViewDef, compViewDefFactory, createAndGetRootNodes, createEmbeddedVi
|
||||||
// 2 anchors + 2 elements
|
// 2 anchors + 2 elements
|
||||||
const rootChildren = rootNodes[0].childNodes;
|
const rootChildren = rootNodes[0].childNodes;
|
||||||
expect(rootChildren.length).toBe(4);
|
expect(rootChildren.length).toBe(4);
|
||||||
expect(getDOM().getAttribute(rootChildren[1], 'name')).toBe('child1');
|
expect(rootChildren[1].getAttribute('name')).toBe('child1');
|
||||||
expect(getDOM().getAttribute(rootChildren[2], 'name')).toBe('child0');
|
expect(rootChildren[2].getAttribute('name')).toBe('child0');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should include embedded views in root nodes', () => {
|
it('should include embedded views in root nodes', () => {
|
||||||
|
@ -107,8 +107,8 @@ import {compViewDef, compViewDefFactory, createAndGetRootNodes, createEmbeddedVi
|
||||||
|
|
||||||
const rootNodes = rootRenderNodes(parentView);
|
const rootNodes = rootRenderNodes(parentView);
|
||||||
expect(rootNodes.length).toBe(3);
|
expect(rootNodes.length).toBe(3);
|
||||||
expect(getDOM().getAttribute(rootNodes[1], 'name')).toBe('child0');
|
expect(rootNodes[1].getAttribute('name')).toBe('child0');
|
||||||
expect(getDOM().getAttribute(rootNodes[2], 'name')).toBe('after');
|
expect(rootNodes[2].getAttribute('name')).toBe('after');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should dirty check embedded views', () => {
|
it('should dirty check embedded views', () => {
|
||||||
|
|
|
@ -340,7 +340,7 @@ import {ARG_TYPE_VALUES, checkNodeInlineOrDynamic, createRootView, createAndGetR
|
||||||
expect(instance.b).toBe('v2');
|
expect(instance.b).toBe('v2');
|
||||||
|
|
||||||
const el = rootNodes[0];
|
const el = rootNodes[0];
|
||||||
expect(getDOM().getAttribute(el, 'ng-reflect-a')).toBe('v1');
|
expect(el.getAttribute('ng-reflect-a')).toBe('v1');
|
||||||
});
|
});
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -23,11 +23,11 @@ export class DOMTestComponentRenderer extends TestComponentRenderer {
|
||||||
const rootEl = <HTMLElement>getContent(template).firstChild;
|
const rootEl = <HTMLElement>getContent(template).firstChild;
|
||||||
|
|
||||||
// TODO(juliemr): can/should this be optional?
|
// 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++) {
|
for (let i = 0; i < oldRoots.length; i++) {
|
||||||
getDOM().remove(oldRoots[i]);
|
getDOM().remove(oldRoots[i]);
|
||||||
}
|
}
|
||||||
getDOM().appendChild(this._doc.body, rootEl);
|
this._doc.body.appendChild(rootEl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -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 {
|
onAndCancel(el: Node, evt: any, listener: any): Function {
|
||||||
el.addEventListener(evt, listener, false);
|
el.addEventListener(evt, listener, false);
|
||||||
// Needed to follow Dart's subscription semantic, until fix of
|
// 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); };
|
return () => { el.removeEventListener(evt, listener, false); };
|
||||||
}
|
}
|
||||||
dispatchEvent(el: Node, evt: any) { el.dispatchEvent(evt); }
|
dispatchEvent(el: Node, evt: any) { el.dispatchEvent(evt); }
|
||||||
appendChild(el: Node, node: Node) { el.appendChild(node); }
|
|
||||||
remove(node: Node): Node {
|
remove(node: Node): Node {
|
||||||
if (node.parentNode) {
|
if (node.parentNode) {
|
||||||
node.parentNode.removeChild(node);
|
node.parentNode.removeChild(node);
|
||||||
|
@ -70,15 +68,6 @@ export class BrowserDomAdapter extends GenericBrowserDomAdapter {
|
||||||
doc = doc || this.getDefaultDocument();
|
doc = doc || this.getDefaultDocument();
|
||||||
return doc.createElement(tagName);
|
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 {
|
createHtmlDocument(): HTMLDocument {
|
||||||
return document.implementation.createHTMLDocument('fakeTitle');
|
return document.implementation.createHTMLDocument('fakeTitle');
|
||||||
}
|
}
|
||||||
|
|
|
@ -65,7 +65,7 @@ export class Meta {
|
||||||
|
|
||||||
getTags(attrSelector: string): HTMLMetaElement[] {
|
getTags(attrSelector: string): HTMLMetaElement[] {
|
||||||
if (!attrSelector) return [];
|
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) : [];
|
return list ? [].slice.call(list) : [];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,13 +99,13 @@ export class Meta {
|
||||||
}
|
}
|
||||||
const element: HTMLMetaElement = this._dom.createElement('meta') as HTMLMetaElement;
|
const element: HTMLMetaElement = this._dom.createElement('meta') as HTMLMetaElement;
|
||||||
this._setMetaElementAttributes(meta, element);
|
this._setMetaElementAttributes(meta, element);
|
||||||
const head = this._dom.getElementsByTagName(this._doc, 'head')[0];
|
const head = this._doc.getElementsByTagName('head')[0];
|
||||||
this._dom.appendChild(head, element);
|
head.appendChild(element);
|
||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
private _setMetaElementAttributes(tag: MetaDefinition, el: HTMLMetaElement): HTMLMetaElement {
|
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;
|
return el;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,6 +115,6 @@ export class Meta {
|
||||||
}
|
}
|
||||||
|
|
||||||
private _containsAttributes(tag: MetaDefinition, elem: HTMLMetaElement): boolean {
|
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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ export function appInitializerFactory(transitionId: string, document: any, injec
|
||||||
const dom = getDOM();
|
const dom = getDOM();
|
||||||
const styles: any[] =
|
const styles: any[] =
|
||||||
Array.prototype.slice.apply(document.querySelectorAll(`style[ng-transition]`));
|
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));
|
.forEach(el => dom.remove(el));
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
|
@ -142,7 +142,7 @@ function bootstrap(
|
||||||
compilerConsole = new DummyConsole();
|
compilerConsole = new DummyConsole();
|
||||||
testProviders = [{provide: Console, useValue: compilerConsole}];
|
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++) {
|
for (let i = 0; i < oldRoots.length; i++) {
|
||||||
getDOM().remove(oldRoots[i]);
|
getDOM().remove(oldRoots[i]);
|
||||||
}
|
}
|
||||||
|
@ -150,9 +150,9 @@ function bootstrap(
|
||||||
el = getDOM().createElement('hello-app', doc);
|
el = getDOM().createElement('hello-app', doc);
|
||||||
el2 = getDOM().createElement('hello-app-2', doc);
|
el2 = getDOM().createElement('hello-app-2', doc);
|
||||||
lightDom = getDOM().createElement('light-dom-el', doc);
|
lightDom = getDOM().createElement('light-dom-el', doc);
|
||||||
getDOM().appendChild(doc.body, el);
|
doc.body.appendChild(el);
|
||||||
getDOM().appendChild(doc.body, el2);
|
doc.body.appendChild(el2);
|
||||||
getDOM().appendChild(el, lightDom);
|
el.appendChild(lightDom);
|
||||||
lightDom.textContent = 'loading';
|
lightDom.textContent = 'loading';
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
@ -440,17 +440,17 @@ function bootstrap(
|
||||||
const platform = platformBrowserDynamic();
|
const platform = platformBrowserDynamic();
|
||||||
const document = platform.injector.get(DOCUMENT);
|
const document = platform.injector.get(DOCUMENT);
|
||||||
const style = dom.createElement('style', document);
|
const style = dom.createElement('style', document);
|
||||||
dom.setAttribute(style, 'ng-transition', 'my-app');
|
style.setAttribute('ng-transition', 'my-app');
|
||||||
dom.appendChild(document.head, style);
|
document.head.appendChild(style);
|
||||||
|
|
||||||
const root = dom.createElement('root', document);
|
const root = dom.createElement('root', document);
|
||||||
dom.appendChild(document.body, root);
|
document.body.appendChild(root);
|
||||||
|
|
||||||
platform.bootstrapModule(TestModule).then(() => {
|
platform.bootstrapModule(TestModule).then(() => {
|
||||||
const styles: HTMLElement[] =
|
const styles: HTMLElement[] =
|
||||||
Array.prototype.slice.apply(dom.getElementsByTagName(document, 'style') || []);
|
Array.prototype.slice.apply(document.getElementsByTagName('style') || []);
|
||||||
styles.forEach(
|
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();
|
async.done();
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -22,9 +22,9 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||||
doc = getDOM().createHtmlDocument();
|
doc = getDOM().createHtmlDocument();
|
||||||
metaService = new Meta(doc);
|
metaService = new Meta(doc);
|
||||||
defaultMeta = getDOM().createElement('meta', doc) as HTMLMetaElement;
|
defaultMeta = getDOM().createElement('meta', doc) as HTMLMetaElement;
|
||||||
getDOM().setAttribute(defaultMeta, 'property', 'fb:app_id');
|
defaultMeta.setAttribute('property', 'fb:app_id');
|
||||||
getDOM().setAttribute(defaultMeta, 'content', '123456789');
|
defaultMeta.setAttribute('content', '123456789');
|
||||||
getDOM().appendChild(getDOM().getElementsByTagName(doc, 'head')[0], defaultMeta);
|
doc.getElementsByTagName('head')[0].appendChild(defaultMeta);
|
||||||
});
|
});
|
||||||
|
|
||||||
afterEach(() => getDOM().remove(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', () => {
|
it('should return meta tag matching selector', () => {
|
||||||
const actual: HTMLMetaElement = metaService.getTag('property="fb:app_id"') !;
|
const actual: HTMLMetaElement = metaService.getTag('property="fb:app_id"') !;
|
||||||
expect(actual).not.toBeNull();
|
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', () => {
|
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');
|
const actual: HTMLMetaElement[] = metaService.getTags('name=author');
|
||||||
expect(actual.length).toEqual(2);
|
expect(actual.length).toEqual(2);
|
||||||
expect(getDOM().getAttribute(actual[0], 'content')).toEqual('page author');
|
expect(actual[0].getAttribute('content')).toEqual('page author');
|
||||||
expect(getDOM().getAttribute(actual[1], 'content')).toEqual('another page author');
|
expect(actual[1].getAttribute('content')).toEqual('another page author');
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
metaService.removeTagElement(tag1);
|
metaService.removeTagElement(tag1);
|
||||||
|
@ -87,7 +87,7 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||||
|
|
||||||
const actual = metaService.getTag(selector);
|
const actual = metaService.getTag(selector);
|
||||||
expect(actual).not.toBeNull();
|
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', () => {
|
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);
|
const actual = metaService.getTag(selector);
|
||||||
expect(actual).not.toBeNull();
|
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', () => {
|
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) !;
|
const actual = metaService.getTag(selector) !;
|
||||||
expect(actual).not.toBeNull();
|
expect(actual).not.toBeNull();
|
||||||
expect(getDOM().getAttribute(actual, 'content')).toEqual('Content Title');
|
expect(actual.getAttribute('content')).toEqual('Content Title');
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
metaService.removeTagElement(actual);
|
metaService.removeTagElement(actual);
|
||||||
|
@ -120,7 +120,7 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||||
|
|
||||||
const actual = metaService.getTag(selector) !;
|
const actual = metaService.getTag(selector) !;
|
||||||
expect(actual).not.toBeNull();
|
expect(actual).not.toBeNull();
|
||||||
expect(getDOM().getAttribute(actual, 'content')).toEqual('Content Title');
|
expect(actual.getAttribute('content')).toEqual('Content Title');
|
||||||
|
|
||||||
// clean up
|
// clean up
|
||||||
metaService.removeTagElement(actual);
|
metaService.removeTagElement(actual);
|
||||||
|
|
|
@ -61,7 +61,7 @@ import {createMouseEvent, el} from '../../../testing/src/browser_util';
|
||||||
it('events are caught when fired from a child', () => {
|
it('events are caught when fired from a child', () => {
|
||||||
const element = el('<div><div></div></div>');
|
const element = el('<div><div></div></div>');
|
||||||
// Workaround for https://bugs.webkit.org/show_bug.cgi?id=122755
|
// 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 child = element.firstChild as Element;
|
||||||
const dispatchedEvent = createMouseEvent('click');
|
const dispatchedEvent = createMouseEvent('click');
|
||||||
|
@ -76,7 +76,7 @@ import {createMouseEvent, el} from '../../../testing/src/browser_util';
|
||||||
|
|
||||||
it('should add and remove global event listeners', () => {
|
it('should add and remove global event listeners', () => {
|
||||||
const element = el('<div><div></div></div>');
|
const element = el('<div><div></div></div>');
|
||||||
getDOM().appendChild(doc.body, element);
|
doc.body.appendChild(element);
|
||||||
const dispatchedEvent = createMouseEvent('click');
|
const dispatchedEvent = createMouseEvent('click');
|
||||||
let receivedEvent: any /** TODO #9100 */ = null;
|
let receivedEvent: any /** TODO #9100 */ = null;
|
||||||
const handler = (e: any /** TODO #9100 */) => { receivedEvent = e; };
|
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 Zone = (window as any)['Zone'];
|
||||||
|
|
||||||
const element = el('<div><div></div></div>');
|
const element = el('<div><div></div></div>');
|
||||||
getDOM().appendChild(doc.body, element);
|
doc.body.appendChild(element);
|
||||||
const dispatchedEvent = createMouseEvent('click');
|
const dispatchedEvent = createMouseEvent('click');
|
||||||
let receivedEvent: any /** TODO #9100 */ = null;
|
let receivedEvent: any /** TODO #9100 */ = null;
|
||||||
let receivedZone: any = null;
|
let receivedZone: any = null;
|
||||||
|
@ -122,7 +122,7 @@ import {createMouseEvent, el} from '../../../testing/src/browser_util';
|
||||||
const Zone = (window as any)['Zone'];
|
const Zone = (window as any)['Zone'];
|
||||||
|
|
||||||
const element = el('<div><div></div></div>');
|
const element = el('<div><div></div></div>');
|
||||||
getDOM().appendChild(doc.body, element);
|
doc.body.appendChild(element);
|
||||||
const dispatchedEvent = createMouseEvent('click');
|
const dispatchedEvent = createMouseEvent('click');
|
||||||
let receivedEvents: any[] /** TODO #9100 */ = [];
|
let receivedEvents: any[] /** TODO #9100 */ = [];
|
||||||
let receivedZones: any[] = [];
|
let receivedZones: any[] = [];
|
||||||
|
@ -157,7 +157,7 @@ import {createMouseEvent, el} from '../../../testing/src/browser_util';
|
||||||
const Zone = (window as any)['Zone'];
|
const Zone = (window as any)['Zone'];
|
||||||
|
|
||||||
const element = el('<div><div></div></div>');
|
const element = el('<div><div></div></div>');
|
||||||
getDOM().appendChild(doc.body, element);
|
doc.body.appendChild(element);
|
||||||
const dispatchedEvent = createMouseEvent('click');
|
const dispatchedEvent = createMouseEvent('click');
|
||||||
let receivedEvents: any[] /** TODO #9100 */ = [];
|
let receivedEvents: any[] /** TODO #9100 */ = [];
|
||||||
let receivedZones: any[] = [];
|
let receivedZones: any[] = [];
|
||||||
|
@ -193,7 +193,7 @@ import {createMouseEvent, el} from '../../../testing/src/browser_util';
|
||||||
const Zone = (window as any)['Zone'];
|
const Zone = (window as any)['Zone'];
|
||||||
|
|
||||||
const element = el('<div><div></div></div>');
|
const element = el('<div><div></div></div>');
|
||||||
getDOM().appendChild(doc.body, element);
|
doc.body.appendChild(element);
|
||||||
const dispatchedEvent = createMouseEvent('click');
|
const dispatchedEvent = createMouseEvent('click');
|
||||||
let receivedEvents: any[] /** TODO #9100 */ = [];
|
let receivedEvents: any[] /** TODO #9100 */ = [];
|
||||||
let receivedZones: any[] = [];
|
let receivedZones: any[] = [];
|
||||||
|
@ -229,7 +229,7 @@ import {createMouseEvent, el} from '../../../testing/src/browser_util';
|
||||||
const Zone = (window as any)['Zone'];
|
const Zone = (window as any)['Zone'];
|
||||||
|
|
||||||
const element = el('<div><div></div></div>');
|
const element = el('<div><div></div></div>');
|
||||||
getDOM().appendChild(doc.body, element);
|
doc.body.appendChild(element);
|
||||||
const dispatchedEvent = createMouseEvent('click');
|
const dispatchedEvent = createMouseEvent('click');
|
||||||
let receivedEvents: any[] /** TODO #9100 */ = [];
|
let receivedEvents: any[] /** TODO #9100 */ = [];
|
||||||
let receivedZones: any[] = [];
|
let receivedZones: any[] = [];
|
||||||
|
@ -260,7 +260,7 @@ import {createMouseEvent, el} from '../../../testing/src/browser_util';
|
||||||
const Zone = (window as any)['Zone'];
|
const Zone = (window as any)['Zone'];
|
||||||
|
|
||||||
const element = el('<div><div></div></div>');
|
const element = el('<div><div></div></div>');
|
||||||
getDOM().appendChild(doc.body, element);
|
doc.body.appendChild(element);
|
||||||
const dispatchedEvent = createMouseEvent('click');
|
const dispatchedEvent = createMouseEvent('click');
|
||||||
let receivedEvents: any[] /** TODO #9100 */ = [];
|
let receivedEvents: any[] /** TODO #9100 */ = [];
|
||||||
let receivedZones: any[] = [];
|
let receivedZones: any[] = [];
|
||||||
|
@ -299,7 +299,7 @@ import {createMouseEvent, el} from '../../../testing/src/browser_util';
|
||||||
it('should run blockListedEvents handler outside of ngZone', () => {
|
it('should run blockListedEvents handler outside of ngZone', () => {
|
||||||
const Zone = (window as any)['Zone'];
|
const Zone = (window as any)['Zone'];
|
||||||
const element = el('<div><div></div></div>');
|
const element = el('<div><div></div></div>');
|
||||||
getDOM().appendChild(doc.body, element);
|
doc.body.appendChild(element);
|
||||||
const dispatchedEvent = createMouseEvent('scroll');
|
const dispatchedEvent = createMouseEvent('scroll');
|
||||||
let receivedEvent: any /** TODO #9100 */ = null;
|
let receivedEvent: any /** TODO #9100 */ = null;
|
||||||
let receivedZone: any = null;
|
let receivedZone: any = null;
|
||||||
|
|
|
@ -78,7 +78,7 @@ export class DominoAdapter extends BrowserDomAdapter {
|
||||||
if (name === 'href') {
|
if (name === 'href') {
|
||||||
// Domino tries to resolve href-s which we do not want. Just return the
|
// Domino tries to resolve href-s which we do not want. Just return the
|
||||||
// attribute value.
|
// attribute value.
|
||||||
return this.getAttribute(el, 'href');
|
return el.getAttribute('href');
|
||||||
} else if (name === 'innerText') {
|
} else if (name === 'innerText') {
|
||||||
// Domino does not support innerText. Just map it to textContent.
|
// Domino does not support innerText. Just map it to textContent.
|
||||||
return el.textContent;
|
return el.textContent;
|
||||||
|
|
|
@ -88,7 +88,7 @@ class DefaultServerRenderer2 implements Renderer2 {
|
||||||
return doc.createTextNode(value);
|
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 {
|
insertBefore(parent: any, newChild: any, refChild: any): void {
|
||||||
if (parent) {
|
if (parent) {
|
||||||
|
@ -126,7 +126,7 @@ class DefaultServerRenderer2 implements Renderer2 {
|
||||||
if (namespace) {
|
if (namespace) {
|
||||||
el.setAttributeNS(NAMESPACE_URIS[namespace], namespace + ':' + name, value);
|
el.setAttributeNS(NAMESPACE_URIS[namespace], namespace + ':' + name, value);
|
||||||
} else {
|
} else {
|
||||||
getDOM().setAttribute(el, name, value);
|
el.setAttribute(name, value);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ export class ServerStylesHost extends SharedStylesHost {
|
||||||
@Inject(DOCUMENT) private doc: any,
|
@Inject(DOCUMENT) private doc: any,
|
||||||
@Optional() @Inject(ɵTRANSITION_ID) private transitionId: string) {
|
@Optional() @Inject(ɵTRANSITION_ID) private transitionId: string) {
|
||||||
super();
|
super();
|
||||||
this.head = getDOM().getElementsByTagName(doc, 'head')[0];
|
this.head = doc.getElementsByTagName('head')[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
private _addStyle(style: string): void {
|
private _addStyle(style: string): void {
|
||||||
|
@ -26,9 +26,9 @@ export class ServerStylesHost extends SharedStylesHost {
|
||||||
const el = adapter.createElement('style');
|
const el = adapter.createElement('style');
|
||||||
el.textContent = style;
|
el.textContent = style;
|
||||||
if (!!this.transitionId) {
|
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)); }
|
onStylesAdded(additions: Set<string>) { additions.forEach(style => this._addStyle(style)); }
|
||||||
|
|
|
@ -473,11 +473,11 @@ class HiddenModule {
|
||||||
}]);
|
}]);
|
||||||
platform.bootstrapModule(ExampleStylesModule).then(ref => {
|
platform.bootstrapModule(ExampleStylesModule).then(ref => {
|
||||||
const doc = ref.injector.get(DOCUMENT);
|
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;
|
const styles: any[] = head.children as any;
|
||||||
expect(styles.length).toBe(1);
|
expect(styles.length).toBe(1);
|
||||||
expect(styles[0].textContent).toContain('color: red');
|
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 => {
|
platform.bootstrapModule(ImageExampleModule).then(ref => {
|
||||||
const appRef: ApplicationRef = ref.injector.get(ApplicationRef);
|
const appRef: ApplicationRef = ref.injector.get(ApplicationRef);
|
||||||
const app = appRef.components[0].location.nativeElement;
|
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');
|
expect(img.attributes['src'].value).toEqual('link');
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
|
@ -44,15 +44,10 @@ export class WorkerDomAdapter extends DomAdapter {
|
||||||
|
|
||||||
getProperty(el: Element, name: string): any { throw 'not implemented'; }
|
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'; }
|
onAndCancel(el: any, evt: any, listener: any): Function { throw 'not implemented'; }
|
||||||
dispatchEvent(el: any, evt: any) { 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'; }
|
remove(el: any): Node { throw 'not implemented'; }
|
||||||
createElement(tagName: any, doc?: any): HTMLElement { 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'; }
|
createHtmlDocument(): HTMLDocument { throw 'not implemented'; }
|
||||||
getDefaultDocument(): Document { throw 'not implemented'; }
|
getDefaultDocument(): Document { throw 'not implemented'; }
|
||||||
isElementNode(node: any): boolean { throw 'not implemented'; }
|
isElementNode(node: any): boolean { throw 'not implemented'; }
|
||||||
|
|
|
@ -121,7 +121,7 @@ let lastCreatedRenderer: Renderer2;
|
||||||
expect(el.style['width']).toEqual('');
|
expect(el.style['width']).toEqual('');
|
||||||
|
|
||||||
lastCreatedRenderer.setAttribute(workerEl, 'someattr', 'someValue');
|
lastCreatedRenderer.setAttribute(workerEl, 'someattr', 'someValue');
|
||||||
expect(getDOM().getAttribute(el, 'someattr')).toEqual('someValue');
|
expect(el.getAttribute('someattr')).toEqual('someValue');
|
||||||
};
|
};
|
||||||
|
|
||||||
// root element
|
// root element
|
||||||
|
|
|
@ -42,15 +42,15 @@ describe('bootstrap', () => {
|
||||||
|
|
||||||
const el1 = getDOM().createElement('test-app', doc);
|
const el1 = getDOM().createElement('test-app', doc);
|
||||||
const el2 = getDOM().createElement('test-app2', doc);
|
const el2 = getDOM().createElement('test-app2', doc);
|
||||||
getDOM().appendChild(doc.body, el1);
|
doc.body.appendChild(el1);
|
||||||
getDOM().appendChild(doc.body, el2);
|
doc.body.appendChild(el2);
|
||||||
|
|
||||||
log = [];
|
log = [];
|
||||||
testProviders = [{provide: APP_BASE_HREF, useValue: ''}];
|
testProviders = [{provide: APP_BASE_HREF, useValue: ''}];
|
||||||
}));
|
}));
|
||||||
|
|
||||||
afterEach(inject([DOCUMENT], (doc: any) => {
|
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++) {
|
for (let i = 0; i < oldRoots.length; i++) {
|
||||||
getDOM().remove(oldRoots[i]);
|
getDOM().remove(oldRoots[i]);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue