-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Add 2.x option to treat complex observers as they were in Polymer1 #5262
Comments
Why not just add at the beginning: if (!foo || !bar) return; Or if (foo === undefined || bar === undefined) return; |
You can also do it like this: if (Array.from(arguments).some(arg => arg === undefined)) |
I am inclined to agree with @jsilvermist and @web-padawan here. It should be quite straightforward to handle these cases. This also makes the logic more explicit. I would therefore be against adding such an option. |
Sorry, I didn't illustrate the real problem very well. It's very clear in this case that you can add: However, I've worked on upgrading an app with many elements, and thousands of places where this can happen, many not as obvious as this. A few examples:
This issue is a huge pain point for large apps with many async properties. My goal is to make it easier to incrementally add the undefined checks as you are suggesting. |
[3.x] Add legacy-data-mixin as 1.x->2.x/3.x migration aide. Fixes #5262.
[2.x] Add legacy-data-mixin as 1.x->2.x migration aide. Fixes #5262.
In order to smooth the upgrade process, add an option at the element level to not call observer/computed functions if any of the arguments is undefined.
Example:
properties: { foo: String, bar: String, baz: { type: String, computed: computedFn(foo, bar), }, usePolymer1StyleObserver: true, }, computedFn(foo, bar) { return foo + bar; }
The text was updated successfully, but these errors were encountered: