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 release-1-13] Ensure concatenatedProperties are not stomped. #12104

Merged
merged 1 commit into from
Aug 15, 2015

Conversation

rwjblue
Copy link
Member

@rwjblue rwjblue commented Aug 14, 2015

When _propagateAttrsToThis is invoked it iterates all properties that are present in this.attrs and calls this.set(attrName, attrValue). This is normally exactly what you expect. However, in the case of concatenatedProperties and mergedProperties this seting causes the concatenated / merged property to be completely clobbered.

The fix introduced in #12073 adds a very simple work around for the internally known items (just hard coding things like classNames, classNameBindings, attributeBindings, and actions). This was obviously a very naive check, and leaves any external usages of concatenatedProperties in components/views completely hosed.


The changes here introduces a __avoidPropagating property that we can use to prevent concatenatedProperties and mergedProperties from being set inside _propagateAttrsToThis. To avoid introducing this cost for every component created (when only classes can define new concatenated / merged properties) we are storing the __avoidPropagating on the constructor itself.

One notable addon that has broken functionality is yapplabs/ember-modal-dialog#71.


Fixes #12099.

Implemented by @rondale-sc and @rwjblue.

@lukemelia
Copy link
Member

Thanks for tracking this down, gents!

this._super(...arguments);

if (!this.constructor.__avoidPropagating) {
this.constructor.__avoidPropagating = dictionary(null);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rwjblue this should likely be an EmptyObject (eventually)

When `_propagateAttrsToThis` is invoked it iterates all properties that
are present in `this.attrs` and calls `this.set(attrName, attrValue)`.
This is normally exactly what you expect. However, in the case of
`concatenatedProperties` and `mergedProperties` this `set`ing causes the
concatenated / merged property to be completely clobbered.

The fix introduced in emberjs#12073 adds a very simple work around for the
internally known items (just hard coding things like `classNames`,
`classNameBindings`, `attributeBindings`, and `actions`). This was
obviously a very naive check, and leaves any external usages of
`concatenatedProperties` in components/views completely hosed.

---

The changes here introduces a __avoidPropagating property that we can
use to prevent `concatenatedProperties` and `mergedProperties` from
being set inside `_propagateAttrsToThis`. To avoid introducing this cost
for every component created (when only classes can define new
concatenated / merged properties) we are storing the
`__avoidPropagating` on the constructor itself.
@rwjblue rwjblue force-pushed the fix-concatenated-properties branch from a92f60e to 98d7cf3 Compare August 14, 2015 21:13
@rwjblue
Copy link
Member Author

rwjblue commented Aug 14, 2015

Updated with some tweaks suggested by @stefanpenner in chat.

@rondale-sc
Copy link
Contributor

@rwjblue Why EmptyObject over dictionary in this case?

@rwjblue
Copy link
Member Author

rwjblue commented Aug 14, 2015

@stefanpenner explained it to me like this in chat:

Use dictionary for long lived dictionary's that will have many add / removes over time.

EmptyObject is like 10x faster than Object.create(null) (which is done by dictionary) and is better suited for this kind of thing because we aren't actually going to delete entries.

@stefanpenner
Copy link
Member

EmptyObject is like 10x faster than Object.create(null) (which is done by dictionary) and is better suited for this kind of thing because we aren't actually going to delete entries.

Dictionary is for things that will most likely be deleted from

dictionary could also use EmptyObject, but its also the deletion that makes it slow (although it would be less slow once moved to EmptyObject)

@rondale-sc
Copy link
Contributor

👍 Thanks. I'm going to look up some of these optimizations so I can have a little bit of a better understanding. :)

rwjblue added a commit that referenced this pull request Aug 15, 2015
[BUGFIX release-1-13] Ensure concatenatedProperties are not stomped.
@rwjblue rwjblue merged commit b53366a into emberjs:master Aug 15, 2015
@rwjblue rwjblue deleted the fix-concatenated-properties branch August 15, 2015 19:20
@sukima
Copy link
Contributor

sukima commented Aug 20, 2015

Will this be part of a bug fix release on version 1.13? This is a show stopper as the expectation declared in the documentation is broken. Many people (including us) can not upgrade to 2.0 yet.

If not can we have a work around best practice to handle the broken behavior till we can upgrade to 2.0?

@rwjblue
Copy link
Member Author

rwjblue commented Aug 20, 2015

@sukima - Yes, we plan to release a 1.13.x version with this fix.

@rondale-sc
Copy link
Contributor

@sukima You can downgrade to 1.13.6 if you need immediate relief. If that is an option of course.

@sukima
Copy link
Contributor

sukima commented Aug 24, 2015

@rwjblue and @rondale-sc thank you!

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.

concatenatedProperties works in 1.13.6 but not obliged in 1.13.7+
5 participants