-
Notifications
You must be signed in to change notification settings - Fork 27.4k
updating exposed scope property within directive's link function cause exception in v1.4.9 #13937
Comments
We've fixed a regression with that in 1.4.9. It's expected that this throws, because you haven't marked your scope definition with Here's the original issue: #13367 So it's not a regression, but it restores the behavior we actually want. The problem is that the original behavior is "lost" since 1.4, so for quite a while. |
Thanks @Narretz ! Maybe a note about it in the "breaking changes" section would assist, because it cause one of my apps to break and it took a while to figure out the reason. |
That's the thing, it's not technically a breaking change, because we fixed a regression. |
Regression or not. It was there for 9 versions over 8 months... This actually breaks applications that might have missed a parameter but continued to work. And its not even listed in the changelog... |
SOOOOOOoooooooo, what this all spells out to me, is that I should just put a question mark after EVERY scope attribute, just to be safe and work like old angular 1.4.7 worked??????? This is whacky and hardly covered in any changelog. |
Don't get me wrong. I am a fan of fixing this behavior. However for us it is a breaking change as in some cases people missed marking properties as optional but treated it as such. However as a very large application it is impossible to know where we might have done this. For now I have upgraded to 1.4.9 / 1.5.0 but modified the angular source to treat it as a warning so we can fix without loss of functionality. Basically reverted: 4473b81 |
Thank you for the reply. I've never needed nor ever used the optional attribute specification even though it seems to have existed since the beginning of Angular. And so for me, I can't see why we need an optional specifier at all, especially when my 1.4.6 code works so great. Specifying something as optional, just doesn't feel like JavaScript at all. But mass adding a ? to all me two-way binds =? fixed my code across the board without checking if any scope attribute actually needs it. Thanks again |
The scope definition is a bit like an interface for your directive. So you can define explicitly to the consumer if a property must be set or can be set. To me that's a strength, not a weakness. |
Narretz, a declaration of an optional attribute, is documentation and should not cause code to break. Yo, nice spin and healthy light on the subject but it was correct for how code should flow in older Angular versions. I should be able to default a scope attribute that wasn't supplied, without specifying it |
Hey, I get it though, directives being interface like and being an implementation contract of sorts. But I'm also just dealing with this "issue" splitting my dick with every directive I've ever made that defaulted an optional scope attribute. O well |
Updating an exposed scope property within directive's link function cause exception in v1.4.9, with not in v1.4.8.
I couldn't find the relevant change in the changelog.
Here is a demo to show the problem:
https://jsfiddle.net/kkop339m/
Change the script tag to import v1.4.9 and run the code with console open.
You will see the following exception:
Same code runs in v1.4.8 with no errors.
The text was updated successfully, but these errors were encountered: