fix(shadowdom): allow conditional content tags.
Distribution is triggered on the host element injector after each new view creation.
This commit is contained in:
@ -9,7 +9,7 @@ import {Optional, Injector, Inject, bind} from 'angular2/di';
|
||||
import {ProtoView, View} from 'angular2/src/core/compiler/view';
|
||||
import {ViewContainer} from 'angular2/src/core/compiler/view_container';
|
||||
import {NgElement} from 'angular2/src/core/dom/element';
|
||||
import {LightDom, SourceLightDom, DestinationLightDom} from 'angular2/src/core/compiler/shadow_dom_emulation/light_dom';
|
||||
import {LightDom, DestinationLightDom} from 'angular2/src/core/compiler/shadow_dom_emulation/light_dom';
|
||||
import {Directive} from 'angular2/src/core/annotations/annotations';
|
||||
import {BindingPropagationConfig} from 'angular2/src/core/compiler/binding_propagation_config';
|
||||
import {DynamicProtoChangeDetector} from 'angular2/change_detection';
|
||||
@ -455,10 +455,10 @@ export function main() {
|
||||
parentPreBuiltObjects = new PreBuiltObjects(null, null, null, lightDom, null);
|
||||
});
|
||||
|
||||
it("should return destination light DOM from the parent's injector", function () {
|
||||
var child = parentChildInjectors([], [], parentPreBuiltObjects);
|
||||
it("should return light DOM from the current injector", function () {
|
||||
var inj = injector([], null, null, parentPreBuiltObjects);
|
||||
|
||||
expect(child.get(DestinationLightDom)).toEqual(lightDom);
|
||||
expect(inj.get(LightDom)).toEqual(lightDom);
|
||||
});
|
||||
|
||||
it("should return null when parent's injector is a component boundary", function () {
|
||||
@ -466,12 +466,6 @@ export function main() {
|
||||
|
||||
expect(child.get(DestinationLightDom)).toBeNull();
|
||||
});
|
||||
|
||||
it("should return source light DOM from the closest component boundary", function () {
|
||||
var child = hostShadowInjectors([], [], parentPreBuiltObjects);
|
||||
|
||||
expect(child.get(SourceLightDom)).toEqual(lightDom);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
|
@ -188,33 +188,32 @@ export function main() {
|
||||
});
|
||||
});
|
||||
|
||||
// Enable once dom-write queue is implemented and onDehydrate is implemented
|
||||
//it('should redistribute when the shadow dom changes', (done) => {
|
||||
// var temp = '<conditional-content>' +
|
||||
// '<div class="left">A</div>' +
|
||||
// '<div>B</div>' +
|
||||
// '<div>C</div>' +
|
||||
// '</conditional-content>';
|
||||
//
|
||||
//
|
||||
// compile(temp, (view, lc) => {
|
||||
// var cmp = view.elementInjectors[0].get(ConditionalContentComponent);
|
||||
//
|
||||
// expect(view.nodes).toHaveText('(, ABC)');
|
||||
//
|
||||
// cmp.showLeft();
|
||||
// lc.tick();
|
||||
//
|
||||
// expect(view.nodes).toHaveText('(A, BC)');
|
||||
//
|
||||
// cmp.hideLeft()
|
||||
// lc.tick();
|
||||
//
|
||||
// expect(view.nodes).toHaveText('(, ABC)');
|
||||
//
|
||||
// done();
|
||||
// });
|
||||
//});
|
||||
it('should redistribute when the shadow dom changes', (done) => {
|
||||
var temp = '<conditional-content>' +
|
||||
'<div class="left">A</div>' +
|
||||
'<div>B</div>' +
|
||||
'<div>C</div>' +
|
||||
'</conditional-content>';
|
||||
|
||||
|
||||
compile(temp, [ConditionalContentComponent, AutoViewportDirective], (view, lc) => {
|
||||
var cmp = view.elementInjectors[0].get(ConditionalContentComponent);
|
||||
|
||||
expect(view.nodes).toHaveText('(, ABC)');
|
||||
|
||||
cmp.showLeft();
|
||||
lc.tick();
|
||||
|
||||
expect(view.nodes).toHaveText('(A, BC)');
|
||||
|
||||
cmp.hideLeft();
|
||||
lc.tick();
|
||||
|
||||
expect(view.nodes).toHaveText('(, ABC)');
|
||||
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
//Implement once NgElement support changing a class
|
||||
//it("should redistribute when a class has been added or removed");
|
||||
@ -300,7 +299,7 @@ class MultipleContentTagsComponent {
|
||||
|
||||
@Component({selector: 'conditional-content'})
|
||||
@Template({
|
||||
inline: '<div>(<div template="auto: cond"><content select=".left"></content></div>, <content></content>)</div>',
|
||||
inline: '<div>(<div *auto="cond"><content select=".left"></content></div>, <content></content>)</div>',
|
||||
directives: [AutoViewportDirective]
|
||||
})
|
||||
class ConditionalContentComponent {
|
||||
|
Reference in New Issue
Block a user