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