Skip to content
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

[BUGFIX LTS] do not throw on stable elementId #18807

Merged
merged 1 commit into from
Mar 11, 2020
Merged

[BUGFIX LTS] do not throw on stable elementId #18807

merged 1 commit into from
Mar 11, 2020

Conversation

chriskrycho
Copy link
Contributor

@chriskrycho chriskrycho commented Mar 11, 2020

When refactoring from observers to setters during the 3.11 release (in 405d423), an apparently-transparent change caused a regression around invocations of components including elementId=.... Any rerender of the component which included elementId assignment now triggered the assertion, rather than only changes which actually updated the value of elementId, because all invocations strigger a set on the property.

The simplest reproduction of this bug (given a component foo-bar):

{{foo-bar
  elementId='stable'
  changingValue=this.fromBackingClass
}}

Changing the value fromBackingClass on the backing class always triggers the assertion, even though it is actually impossible for it to change the elementId value, because the assertion in the setter throws regardless of what the value is. (The observer-based did not throw in the same conditions because it would not retrigger when the observed key on the view did not change.)

The fix is to check equality between the passed elementId value and the previously set value, and only throw if they differ.

Fixes #18147

@chriskrycho
Copy link
Contributor Author

@rwjblue @pzuraq I would definitely appreciate your eyes on this change!

When refactoring from observers to setters during the 3.11 release
(in 405d423), an apparently-transparent change caused a regression
around invocations of components including `elementId=...`. *Any*
rerender of the component which included `elementId` assignment now
triggered the assertion, rather than *only* changes which actually
updated the value of `elementId`, because all invocations strigger
a `set` on the property.

The simplest reproduction of this bug (given a component `foo-bar`):

    {{foo-bar
      elementId='stable'
      changingValue=this.fromBackingClass
    }}

Changing the value `fromBackingClass` on the backing class *always*
triggers the assertion, even though it is actually impossible for
it to change the `elementId` value, because the assertion in the
setter throws regardless of what the value is. (The observer-based
did not throw in the same conditions because it would not retrigger
when the observed key on the view did not change.)

The fix is to check equality between the passed `elementId` value
and the previously set value, and only throw if they differ.

Fixes #18147
@pzuraq
Copy link
Contributor

pzuraq commented Mar 11, 2020

Looks good, thanks for getting this done!

@pzuraq pzuraq merged commit 51acff4 into emberjs:master Mar 11, 2020
@chriskrycho chriskrycho deleted the elementId-regression-18147 branch March 11, 2020 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3.11 regression when using "elementId" in templates
2 participants