fix(compiler): add missing support to string literals
Fixes #531 Closes #559
This commit is contained in:
@ -65,14 +65,23 @@ export function main() {
|
||||
});
|
||||
|
||||
it('should consume directive watch expression change.', (done) => {
|
||||
compiler.compile(MyComp, el('<div my-dir [elprop]="ctxProp"></div>')).then((pv) => {
|
||||
var tpl =
|
||||
'<div>' +
|
||||
'<div my-dir [elprop]="ctxProp"></div>' +
|
||||
'<div my-dir elprop="Hi there!"></div>' +
|
||||
'<div my-dir elprop="Hi {{\'there!\'}}"></div>' +
|
||||
'<div my-dir elprop="One more {{ctxProp}}"></div>' +
|
||||
'</div>'
|
||||
compiler.compile(MyComp, el(tpl)).then((pv) => {
|
||||
createView(pv);
|
||||
|
||||
ctx.ctxProp = 'Hello World!';
|
||||
cd.detectChanges();
|
||||
|
||||
var elInj = view.elementInjectors[0];
|
||||
expect(elInj.get(MyDir).dirProp).toEqual('Hello World!');
|
||||
expect(view.elementInjectors[0].get(MyDir).dirProp).toEqual('Hello World!');
|
||||
expect(view.elementInjectors[1].get(MyDir).dirProp).toEqual('Hi there!');
|
||||
expect(view.elementInjectors[2].get(MyDir).dirProp).toEqual('Hi there!');
|
||||
expect(view.elementInjectors[3].get(MyDir).dirProp).toEqual('One more Hello World!');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
@ -24,6 +24,7 @@ export function main() {
|
||||
directives = [
|
||||
SomeDecorator,
|
||||
SomeDecoratorIgnoringChildren,
|
||||
SomeDecoratorWithBinding,
|
||||
SomeTemplate,
|
||||
SomeTemplate2,
|
||||
SomeComponent,
|
||||
@ -182,6 +183,15 @@ export function main() {
|
||||
);
|
||||
}).toThrowError('Only template directives are allowed on <template> elements!');
|
||||
});
|
||||
|
||||
it('should not instantiate decorator directive twice', () => {
|
||||
var pipeline = createPipeline({propertyBindings: {
|
||||
'some-decor-with-binding': 'someExpr'
|
||||
}});
|
||||
var results = pipeline.process(el('<div some-decor-with-binding="foo"></div>'));
|
||||
expect(results[0].decoratorDirectives.length).toEqual(1);
|
||||
expect(results[0].decoratorDirectives).toEqual([reader.read(SomeDecoratorWithBinding)]);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
@ -208,6 +218,14 @@ class SomeDecorator {}
|
||||
class SomeDecoratorIgnoringChildren {
|
||||
}
|
||||
|
||||
@Decorator({
|
||||
selector: '[some-decor-with-binding]',
|
||||
bind: {
|
||||
'some-decor-with-binding': 'foo'
|
||||
}
|
||||
})
|
||||
class SomeDecoratorWithBinding {}
|
||||
|
||||
@Template({
|
||||
selector: '[some-templ]'
|
||||
})
|
||||
|
@ -73,7 +73,7 @@ export function main() {
|
||||
} else if (isPresent(parent)) {
|
||||
current.inheritedProtoView = parent.inheritedProtoView;
|
||||
}
|
||||
}), new ElementBinderBuilder()
|
||||
}), new ElementBinderBuilder(parser, null)
|
||||
]);
|
||||
}
|
||||
|
||||
@ -312,6 +312,18 @@ export function main() {
|
||||
expect(view.elementInjectors[1].get(SomeDecoratorDirectiveWithBinding).decorProp).toBe('a');
|
||||
});
|
||||
|
||||
it('should bind to string literals', () => {
|
||||
var directives = [SomeDecoratorDirectiveWithBinding];
|
||||
var protoElementInjector = new ProtoElementInjector(null, 0, directives);
|
||||
var pipeline = createPipeline({directives: directives, protoElementInjector: protoElementInjector});
|
||||
var results = pipeline.process(el('<div viewroot directives boundprop1="foo"></div>'));
|
||||
var pv = results[0].inheritedProtoView;
|
||||
instantiateView(pv);
|
||||
changeDetector.detectChanges();
|
||||
|
||||
expect(view.elementInjectors[0].get(SomeDecoratorDirectiveWithBinding).decorProp).toEqual('foo');
|
||||
});
|
||||
|
||||
describe('errors', () => {
|
||||
|
||||
it('should throw if there is no element property bindings for a directive property binding', () => {
|
||||
|
Reference in New Issue
Block a user