feat(compiler): make directive bindings optional. Fixes #647
This commit is contained in:
@ -151,6 +151,20 @@ export function main() {
|
||||
});
|
||||
});
|
||||
|
||||
it('should support directives where a binding attribute is not given', function(done) {
|
||||
tplResolver.setTemplate(MyComp,
|
||||
new Template({
|
||||
// No attribute "el-prop" specified.
|
||||
inline: '<p my-dir></p>',
|
||||
directives: [MyDir]
|
||||
}));
|
||||
|
||||
compiler.compile(MyComp).then((pv) => {
|
||||
createView(pv);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should support template directives via `<template>` elements.', (done) => {
|
||||
tplResolver.setTemplate(MyComp,
|
||||
new Template({
|
||||
|
@ -430,11 +430,15 @@ export function main() {
|
||||
|
||||
describe('errors', () => {
|
||||
|
||||
it('should throw if there is no element property bindings for a directive property binding', () => {
|
||||
var pipeline = createPipeline({propertyBindings: MapWrapper.create(), directives: [SomeDecoratorDirectiveWithBinding]});
|
||||
expect( () => {
|
||||
pipeline.process(el('<div viewroot prop-binding directives>'));
|
||||
}).toThrowError("No element binding found for property 'boundprop1' which is required by directive 'SomeDecoratorDirectiveWithBinding'");
|
||||
it('should not throw any errors if there is no element property bindings for a directive ' +
|
||||
'property binding', () => {
|
||||
var pipeline = createPipeline({
|
||||
propertyBindings: MapWrapper.create(),
|
||||
directives: [SomeDecoratorDirectiveWithBinding]
|
||||
});
|
||||
|
||||
// If processing throws an error, this test will fail.
|
||||
pipeline.process(el('<div viewroot prop-binding directives>'));
|
||||
});
|
||||
|
||||
});
|
||||
|
Reference in New Issue
Block a user