-
-
Notifications
You must be signed in to change notification settings - Fork 4.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
Remove meta.descs
#10323
Remove meta.descs
#10323
Conversation
@@ -119,7 +119,8 @@ function lazyGet(obj, key) { | |||
} | |||
|
|||
// if a CP only return cached value | |||
var desc = meta && meta.descs[key]; | |||
var possibleDesc = obj[key]; | |||
var desc = (possibleDesc !== null && typeof possibleDesc === 'object' && possibleDesc.isDescriptor) ? possibleDesc : undefined; |
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.
I would like a bikeshedding around the fastest/safest way to check if it's a descriptor @stefanpenner @krisselden
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 verbose this is likely the best mechanism to check.
Alternatively, as meta.descs
is internal, and we vow never to set it to null
rather undefined or a value, we wouldn't need the null
check. That being said, the null
check is essentially free.
327d3eb
to
c3f13e8
Compare
@@ -303,7 +302,7 @@ function Meta(obj) { | |||
} | |||
|
|||
Meta.prototype = { | |||
chainWatchers: null | |||
chainWatchers: null // FIXME |
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.
ya, we should fix this, should be easy
I suspect having the descriptor be the property will also be less "magical" But lets see how people react. We should confirm that ember-data behaves correctly with this patch, as it and reduce computed often reach around some of the private meta API |
Now, that Until 1.10.0 my following code was working (although I expected it to be pretty "unstable" as it relied on _stripComputedPropertiesFromModel: function (model) {
var serializedProperties = get(model, 'serializableProperties');
var descs = model.__ember_meta__.descs;
return serializedProperties.filter(function (property) {
return !(descs[property] instanceof ComputedProperty);
});
} |
Try this..
When you access the properties directly on the object - without using .get() - it returns the computed property |
thanks @jmurphyau - I tried it in a JSBin example, but it doesn't seem to work? |
@herom that JSBin still has meta.descs - it was using Ember 1.10.. Also the check wasn't complete.. I've added a bit more detail - an Ember.computed.alias isn't an instance of an Ember.ComputedProperty. Take a look at this JSBin using Ember 1.11 |
thanks a lot @jmurphyau - that's great! 👍 |
As the comment in the code says, this is no longer needed since emberjs/ember.js#10323 was merged in.
@stefanpenner @krisselden @mmun One less allocation in meta. This also means we dont need to instantiate a meta object just to add a computed property to a POJO.