-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix($compile): be more careful about shadowing $attrs values #12151
Conversation
It is also true that this affects the isolated scope as well as the bindToController:
|
Apart from adding a check for the isolated scope, this LGTM |
added |
} | ||
|
||
attrs.$observe(attrName, function(value) { |
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.
Slightly unrelated to this fix, but should we be bothering to call $observe
at all if the attribute doesn't exist?
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.
It might exist later, I think that's the reasoning behind this
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.
The problem is that if you have a one-time binding and the value is sometimes expected to be not defined then in many cases you basically have to write attribute="::null"
. This is very unintuitive and it's very easy to create lots of excessive bindings.
Changing that might be a breaking change, though. But it might be worth doing in 1.5?
Shadows only when attributes are non-optional and not own properties, only stores the observed '@' values when they are indeed strings. Partial revert of 6339d30d1379689da5eec9647a953f64821f8b0
Note that it also happens with new scope and bindToController (e.g. Also note that the case where something is returned from the controller behaves differently, so (if one wanted to be thorough) both cases should be tested. In any case, if I had to choose, I would prefer to have the version where something is returned from the controller, as it is the most fragile one: controller: function () {
...
return <something>; |
Honestly trying every permutation of it is going to add like 300 lines, it's the same paths being taken for each one. Let's keep it for now and add more in a follow-up |
I don't feel strongly about it, so it lgtm. |
Yeah lets do it in a followup. in a meeting atm, if someone else wants to land this |
…esent Shadows only when attributes are non-optional and not own properties, only stores the observed '@' values when they are indeed strings. Partial revert of 6339d30d1379689da5eec9647a953f64821f8b0 Closes angular#12151 Closes angular#12144
Shadows only when attributes are non-optional and not own properties,
only stores the observed '@' values when they are indeed strings.
Partial revert of a6339d3
Closes #12144