fix(platform-browser): insert APP_ID in styles, contentAttr and hostAttr (#17745)

PR Close #17745
This commit is contained in:
Peter Johan Salomonsen
2017-06-24 21:09:38 +02:00
committed by Igor Minar
parent 3ea8d651cc
commit 712d60e467
7 changed files with 19 additions and 16 deletions

View File

@ -27,7 +27,8 @@ describe('functional test for todo', () => {
const toDoAppComponent = (window as any).toDoAppComponent;
await whenRendered(toDoAppComponent);
const styleContent = findStyleTextForSelector('.todo-list\\\[_ngcontent-\\\w+\\\]');
const styleContent =
findStyleTextForSelector('.todo-list\\\[_ngcontent-[a-z]+-\\\w+\\\]');
expect(styleContent).toMatch(/font-weight:\s*bold;/);
expect(styleContent).toMatch(/color:\s*#d9d9d9;/);
}));

View File

@ -348,14 +348,14 @@ describe('encapsulation', () => {
renderComponent(WrapperComponent, {rendererFactory: getRendererFactory2(document)});
expect(containerEl.outerHTML)
.toMatch(
/<div host=""><encapsulated _nghost-c(\d+)="">foo<leaf _ngcontent-c\1=""><span>bar<\/span><\/leaf><\/encapsulated><\/div>/);
/<div host=""><encapsulated _nghost-[a-z]+-c(\d+)="">foo<leaf _ngcontent-[a-z]+-c\1=""><span>bar<\/span><\/leaf><\/encapsulated><\/div>/);
});
it('should encapsulate host', () => {
renderComponent(EncapsulatedComponent, {rendererFactory: getRendererFactory2(document)});
expect(containerEl.outerHTML)
.toMatch(
/<div host="" _nghost-c(\d+)="">foo<leaf _ngcontent-c\1=""><span>bar<\/span><\/leaf><\/div>/);
/<div host="" _nghost-[a-z]+-c(\d+)="">foo<leaf _ngcontent-[a-z]+-c\1=""><span>bar<\/span><\/leaf><\/div>/);
});
it('should encapsulate host and children with different attributes', () => {
@ -401,7 +401,7 @@ describe('encapsulation', () => {
renderComponent(WrapperComponentWith, {rendererFactory: getRendererFactory2(document)});
expect(containerEl.outerHTML)
.toMatch(
/<div host="" _nghost-c(\d+)=""><leaf _ngcontent-c\1="" _nghost-c(\d+)=""><span _ngcontent-c\2="">bar<\/span><\/leaf><\/div>/);
/<div host="" _nghost-[a-z]+-c(\d+)=""><leaf _ngcontent-[a-z]+-c\1="" _nghost-[a-z]+-c(\d+)=""><span _ngcontent-[a-z]+-c\2="">bar<\/span><\/leaf><\/div>/);
});
});

View File

@ -35,7 +35,7 @@ export function getRendererFactory2(document: any): RendererFactory2 {
const fakeNgZone: NgZone = new NoopNgZone();
const eventManager = new EventManager([new SimpleDomEventsPlugin(document)], fakeNgZone);
const rendererFactory =
new ɵDomRendererFactory2(eventManager, new ɵDomSharedStylesHost(document));
new ɵDomRendererFactory2(eventManager, new ɵDomSharedStylesHost(document), 'dummyappid');
const origCreateRenderer = rendererFactory.createRenderer;
rendererFactory.createRenderer = function() {
const renderer = origCreateRenderer.apply(this, arguments);

View File

@ -1123,7 +1123,7 @@ describe('providers', () => {
fixture.update();
expect(fixture.html)
.toMatch(
/<host-cmp>foo<\/host-cmp><embedded-cmp _nghost-c(\d+)="">From module injector<\/embedded-cmp>/);
/<host-cmp>foo<\/host-cmp><embedded-cmp _nghost-[a-z]+-c(\d+)="">From module injector<\/embedded-cmp>/);
});
it('should cross the root view boundary to the parent of the host, thanks to the default root view injector',