-
Notifications
You must be signed in to change notification settings - Fork 25.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(compiler): detect dangling property bindings #2598
feat(compiler): detect dangling property bindings #2598
Conversation
This is part of #2014 that takes only run-time generated schema into account. Opening this one asap to validate the approach (collecting property bindings and directive bindings in compile steps - we do it anyway - and do verifications in the |
58b91e5
to
01ffa28
Compare
@@ -232,7 +232,7 @@ class CellData { | |||
</tbody> | |||
<tbody template="ng-switch-when 'interpolationAttr'"> | |||
<tr template="ng-for #row of data"> | |||
<td template="ng-for #column of row" i="{{column.i}}" j="{{column.j}}"> | |||
<td template="ng-for #column of row" attr.i="{{column.i}}" attr.j="{{column.j}}"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tbosch I hope that this doesn't change the nature of this test too much - I had to modify this one as we don't support binding to non-existing properties after this change.
@mhevery this is first step of full schema support that detects bindings to non-existing properties. It would be great if this one could be reviewed / approach validated so I can move on. |
01ffa28
to
72d3a53
Compare
@@ -151,6 +151,7 @@ export class DirectiveParser implements CompileStep { | |||
var fullExpAstWithBindPipes = this._parser.addPipes(bindingAst, pipes); | |||
directiveBinderBuilder.bindProperty(dirProperty, fullExpAstWithBindPipes); | |||
} | |||
compileElement.bindElement().bindPropertyToDirective(dashCaseToCamelCase(elProp)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need this extra information? The ProtoViewBuilder
has all binding information of the element and all of it's directives already...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tbosch I believe that we need it due to the properties re-mapping. When we bind to directives we know only about property name on the directive side, but not about the original property binding.
72d3a53
to
7d30007
Compare
@tbosch I've rebased it, PTAL |
b1a53ba
to
69cbb0f
Compare
|
||
PromiseWrapper.catchError(tb.createView(MyComp, {context: ctx}), (e) => { | ||
expect(e.message).toEqual( | ||
`Can't bind to 'unknown' since it isn't a know property of the 'div' element`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change error to include:
Can't bind to 'unknown' since it isn't a know property of the 'div' element, and there are no directives present which can accept that value.
Or something like that.
69cbb0f
to
0b61210
Compare
BREAKING CHANGE: compiler will throw on binding to non-existing properties. Till now it was possible to have a binding to a non-existing property, ex.: `<div [foo]="exp">`. From now on this is compilation error - any property binding needs to have at least one associated property: eaither on an HTML element or on any directive associated with a given element (directives' properites need to be declared using the `properties` field in the `@Directive` / `@Component` annotation). Closes angular#2598
0b61210
to
d7b9345
Compare
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
BREAKING CHANGE: compiler will throw on binding to non-existing properties.
Till now it was possible to have a binding to a non-existing property,
ex.:
<div [foo]="exp">
. From now on this is compilation error - anyproperty binding needs to have at least one associated property:
eaither on an HTML element or on any directive associated with a
given element (directives' properites need to be declared using the
properties
field in the@Directive
/@Component
annotation).