diff --git a/modules/angular2/src/render/dom/view/proto_view_builder.ts b/modules/angular2/src/render/dom/view/proto_view_builder.ts index 51cf66b355..8194a64914 100644 --- a/modules/angular2/src/render/dom/view/proto_view_builder.ts +++ b/modules/angular2/src/render/dom/view/proto_view_builder.ts @@ -93,7 +93,7 @@ export class ProtoViewBuilder { propertyBindings: dbb.propertyBindings, eventBindings: dbb.eventBindings, hostPropertyBindings: buildElementPropertyBindings(schemaRegistry, ebb.element, true, - dbb.hostPropertyBindings, new Set()) + dbb.hostPropertyBindings, null) }); }); var nestedProtoView = @@ -336,9 +336,15 @@ function buildElementPropertyBindings( if (isValidElementPropertyBinding(schemaRegistry, protoElement, isNgComponent, propertyBinding)) { propertyBindings.push(propertyBinding); - } else if (!SetWrapper.has(directiveTempaltePropertyNames, propertyNameInTemplate)) { - throw new BaseException( - `Can't bind to '${propertyNameInTemplate}' since it isn't a known property of the '<${DOM.tagName(protoElement).toLowerCase()}>' element and there are no matching directives with a corresponding property`); + } else if (!isPresent(directiveTempaltePropertyNames) || + !SetWrapper.has(directiveTempaltePropertyNames, propertyNameInTemplate)) { + // directiveTempaltePropertyNames is null for host property bindings + var exMsg = + `Can't bind to '${propertyNameInTemplate}' since it isn't a known property of the '<${DOM.tagName(protoElement).toLowerCase()}>' element`; + if (isPresent(directiveTempaltePropertyNames)) { + exMsg += ' and there are no matching directives with a corresponding property'; + } + throw new BaseException(exMsg); } }); return propertyBindings; diff --git a/modules/angular2/test/render/dom/view/proto_view_builder_spec.ts b/modules/angular2/test/render/dom/view/proto_view_builder_spec.ts index 5720c45faf..3c4b2642fa 100644 --- a/modules/angular2/test/render/dom/view/proto_view_builder_spec.ts +++ b/modules/angular2/test/render/dom/view/proto_view_builder_spec.ts @@ -44,6 +44,15 @@ export function main() { expect(() => builder.build(new DomElementSchemaRegistry())).not.toThrow(); }); + it('should throw for unknown host properties even if another directive uses it', () => { + var binder = builder.bindElement(el('
')); + binder.bindDirective(0).bindProperty('someDirProperty', emptyExpr(), 'someDirProperty'); + binder.bindDirective(1).bindHostProperty('someDirProperty', emptyExpr()); + expect(() => builder.build(new DomElementSchemaRegistry())) + .toThrowError( + `Can't bind to 'someDirProperty' since it isn't a known property of the '