parent
fecf768f43
commit
d2cfc6a719
|
@ -58,7 +58,6 @@ module.exports = function(config) {
|
||||||
'dist/all/@angular/**/*node_only_spec.js',
|
'dist/all/@angular/**/*node_only_spec.js',
|
||||||
'dist/all/@angular/benchpress/**',
|
'dist/all/@angular/benchpress/**',
|
||||||
'dist/all/@angular/compiler-cli/**',
|
'dist/all/@angular/compiler-cli/**',
|
||||||
'dist/all/@angular/core/test/render3/**',
|
|
||||||
'dist/all/@angular/compiler/test/aot/**',
|
'dist/all/@angular/compiler/test/aot/**',
|
||||||
'dist/all/@angular/examples/**/e2e_test/*',
|
'dist/all/@angular/examples/**/e2e_test/*',
|
||||||
'dist/all/@angular/language-service/**',
|
'dist/all/@angular/language-service/**',
|
||||||
|
|
|
@ -264,6 +264,14 @@ export function createLNode(
|
||||||
//// Render
|
//// Render
|
||||||
//////////////////////////
|
//////////////////////////
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Resets the application state.
|
||||||
|
*/
|
||||||
|
function resetApplicationState() {
|
||||||
|
isParent = false;
|
||||||
|
previousOrParentNode = null !;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @param host Existing node to render into.
|
* @param host Existing node to render into.
|
||||||
|
@ -274,6 +282,7 @@ export function renderTemplate<T>(
|
||||||
hostNode: RElement, template: ComponentTemplate<T>, context: T,
|
hostNode: RElement, template: ComponentTemplate<T>, context: T,
|
||||||
providedRendererFactory: RendererFactory3, host: LElement | null): LElement {
|
providedRendererFactory: RendererFactory3, host: LElement | null): LElement {
|
||||||
if (host == null) {
|
if (host == null) {
|
||||||
|
resetApplicationState();
|
||||||
rendererFactory = providedRendererFactory;
|
rendererFactory = providedRendererFactory;
|
||||||
host = createLNode(
|
host = createLNode(
|
||||||
null, LNodeFlags.Element, hostNode,
|
null, LNodeFlags.Element, hostNode,
|
||||||
|
@ -499,6 +508,7 @@ export function locateHostElement(
|
||||||
* @param rNode Render host element.
|
* @param rNode Render host element.
|
||||||
*/
|
*/
|
||||||
export function hostElement(rNode: RElement | null, def: ComponentDef<any>) {
|
export function hostElement(rNode: RElement | null, def: ComponentDef<any>) {
|
||||||
|
resetApplicationState();
|
||||||
createLNode(
|
createLNode(
|
||||||
0, LNodeFlags.Element, rNode, createViewState(-1, renderer, getTemplateStatic(def.template)));
|
0, LNodeFlags.Element, rNode, createViewState(-1, renderer, getTemplateStatic(def.template)));
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
import {ViewEncapsulation} from '../../src/core';
|
import {ViewEncapsulation} from '../../src/core';
|
||||||
import {D, E, T, b, defineComponent, e, markDirty, t} from '../../src/render3/index';
|
import {D, E, T, b, defineComponent, e, markDirty, t} from '../../src/render3/index';
|
||||||
import {createRendererType2} from '../../src/view';
|
import {createRendererType2} from '../../src/view/index';
|
||||||
|
|
||||||
import {getRendererFactory2} from './imported_renderer2';
|
import {getRendererFactory2} from './imported_renderer2';
|
||||||
import {containerEl, renderComponent, requestAnimationFrame} from './render_util';
|
import {containerEl, renderComponent, requestAnimationFrame} from './render_util';
|
||||||
|
@ -117,15 +117,15 @@ describe('encapsulation', () => {
|
||||||
it('should encapsulate children, but not host nor grand children', () => {
|
it('should encapsulate children, but not host nor grand children', () => {
|
||||||
renderComponent(WrapperComponent, getRendererFactory2(document));
|
renderComponent(WrapperComponent, getRendererFactory2(document));
|
||||||
expect(containerEl.outerHTML)
|
expect(containerEl.outerHTML)
|
||||||
.toEqual(
|
.toMatch(
|
||||||
'<div host=""><encapsulated _nghost-c0="">foo<leaf _ngcontent-c0=""><span>bar</span></leaf></encapsulated></div>');
|
/<div host=""><encapsulated _nghost-c(\d+)="">foo<leaf _ngcontent-c\1=""><span>bar<\/span><\/leaf><\/encapsulated><\/div>/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should encapsulate host', () => {
|
it('should encapsulate host', () => {
|
||||||
renderComponent(EncapsulatedComponent, getRendererFactory2(document));
|
renderComponent(EncapsulatedComponent, getRendererFactory2(document));
|
||||||
expect(containerEl.outerHTML)
|
expect(containerEl.outerHTML)
|
||||||
.toEqual(
|
.toMatch(
|
||||||
'<div host="" _nghost-c0="">foo<leaf _ngcontent-c0=""><span>bar</span></leaf></div>');
|
/<div host="" _nghost-c(\d+)="">foo<leaf _ngcontent-c\1=""><span>bar<\/span><\/leaf><\/div>/);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should encapsulate host and children with different attributes', () => {
|
it('should encapsulate host and children with different attributes', () => {
|
||||||
|
@ -167,7 +167,7 @@ describe('encapsulation', () => {
|
||||||
|
|
||||||
renderComponent(WrapperComponentWith, getRendererFactory2(document));
|
renderComponent(WrapperComponentWith, getRendererFactory2(document));
|
||||||
expect(containerEl.outerHTML)
|
expect(containerEl.outerHTML)
|
||||||
.toEqual(
|
.toMatch(
|
||||||
'<div host="" _nghost-c2=""><leaf _ngcontent-c2="" _nghost-c3=""><span _ngcontent-c3="">bar</span></leaf></div>');
|
/<div host="" _nghost-c(\d+)=""><leaf _ngcontent-c\1="" _nghost-c(\d+)=""><span _ngcontent-c\2="">bar<\/span><\/leaf><\/div>/);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -35,7 +35,10 @@ requestAnimationFrame.flush = function() {
|
||||||
export function resetDOM() {
|
export function resetDOM() {
|
||||||
requestAnimationFrame.queue = [];
|
requestAnimationFrame.queue = [];
|
||||||
if (containerEl) {
|
if (containerEl) {
|
||||||
|
try {
|
||||||
document.body.removeChild(containerEl);
|
document.body.removeChild(containerEl);
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
}
|
}
|
||||||
containerEl = document.createElement('div');
|
containerEl = document.createElement('div');
|
||||||
containerEl.setAttribute('host', '');
|
containerEl.setAttribute('host', '');
|
||||||
|
|
|
@ -10,8 +10,8 @@ import {AnimationEvent} from '@angular/animations';
|
||||||
import {MockAnimationDriver, MockAnimationPlayer} from '@angular/animations/browser/testing';
|
import {MockAnimationDriver, MockAnimationPlayer} from '@angular/animations/browser/testing';
|
||||||
|
|
||||||
import {RendererType2, ViewEncapsulation} from '../../src/core';
|
import {RendererType2, ViewEncapsulation} from '../../src/core';
|
||||||
import {D, E, L, T, b, defineComponent, detectChanges, e, p} from '../../src/render3';
|
import {D, E, L, T, b, defineComponent, detectChanges, e, p} from '../../src/render3/index';
|
||||||
import {createRendererType2} from '../../src/view';
|
import {createRendererType2} from '../../src/view/index';
|
||||||
|
|
||||||
import {getAnimationRendererFactory2, getRendererFactory2} from './imported_renderer2';
|
import {getAnimationRendererFactory2, getRendererFactory2} from './imported_renderer2';
|
||||||
import {containerEl, document, renderComponent, renderToHtml} from './render_util';
|
import {containerEl, document, renderComponent, renderToHtml} from './render_util';
|
||||||
|
@ -185,7 +185,7 @@ describe('animation renderer factory', () => {
|
||||||
const factory = getAnimationRendererFactory2(document);
|
const factory = getAnimationRendererFactory2(document);
|
||||||
const component = renderComponent(SomeComponentWithAnimation, factory);
|
const component = renderComponent(SomeComponentWithAnimation, factory);
|
||||||
expect(containerEl.innerHTML)
|
expect(containerEl.innerHTML)
|
||||||
.toEqual('<div class="ng-tns-c1-0 ng-trigger ng-trigger-myAnimation">foo</div>');
|
.toMatch(/<div class="ng-tns-c\d+-0 ng-trigger ng-trigger-myAnimation">foo<\/div>/);
|
||||||
|
|
||||||
component.exp = 'on';
|
component.exp = 'on';
|
||||||
detectChanges(component);
|
detectChanges(component);
|
||||||
|
|
Loading…
Reference in New Issue