Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Although this prevents the method from running, it will result in
undefined
being returned fromrunMethodEffect
, and bothrunComputedEffect
andrunBindingEffect
use the return value to take further action (assign to a host property and bound element's property, respectively), which would be another change in behavior. So the flag technically needs to prevent those side-effects in a couple of other places for behavior parity with 1.x.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.
Hmm 🤔, on second thought: in Polymer 2, users won't be able to precisely match the Polymer 1 behavior (not assigning to computing functions) themselves by manually adding
undefined
argument checks to their methods. So perhaps it is better to not try to match it when the flag is enabled, since any issues due to it would still be issues once the flag is removed.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.
What's an example of a time where the behavior would be different?
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's pretty obscure... It would be something like this:
In Polymer 1:
In Polymer 2, by returning early from
runMethodEffect
(and thus returningundefined
as the computed value):... since a return value of
undefined
fromrunMethodEffect
doesn't abort the effect of the binding; it just sets that value (undefined
).Whether the difference would be observable depends on how
x-child
observesprop
, and what legacyundefined
rules it hit in there. In the end, I'm not sure the difference matters; just getting the warning and knowing to do something sensible re: checking for undefined is going to solve most issues I think.