after updating ember-cli to v0.2.7 with ember v.1.12.0 I'm having some funny behavior that causes an exception when using computed properties.
Used model:
User = Ember.Object.extend
md5: ""
gravatar: (->
return get_gravatar(@get("md5"))
).property("md5")
Calling u.get("gravatar")
in the router, afterModel
method, I get this:
u.get("gravatar")
ember.debug.js:15588 Uncaught TypeError: desc.get is not a function
at Object.get (../vendor.js:26142:19)
at exports.default.mixin.Mixin.create.get (../vendor.js:39811:27)
at eval (eval at evaluate (unknown source), <anonymous>:1:3)
at Object.InjectedScript._evaluateOn (<anonymous>:895:55)
at Object.InjectedScript._evaluateAndWrap (<anonymous>:828:34)
at Object.InjectedScript.evaluateOnCallFrame (<anonymous>:954:21)
at afterModel (../v4.js:3438:16)
at applyHook (../vendor.js:55667:32)
at Object.HandlerInfo.runSharedModelHook (../vendor.js:53668:22)
at Object.HandlerInfo.runAfterModelHook (../vendor.js:53651:21)
When digging a bit deeper I saw that the error happens in `ember.debug.js at the getter function.
function get(obj, keyName) {
...
if (desc) {
return desc.get(obj, keyName);
// -> Error while processing route: recipe_edit desc.get is not a function TypeError: desc.get is not a function
} else {
...
The type of desc
was the same as when I called u.gravatar
directly, so I'm not quite sure why this doesn't get resolved anymore.
desc: Object
_cacheable: true
_dependentKeys: Array[1]
_readOnly: false
isDescriptor: true
__proto__: Object
After some hours of debugging I figured out the problem myself. I have a serializer that resolves circular references and removes all unnecessary attributes from my Ember Object to convert it into a JSON.
In the previous Ember version it worked fine, but in this version somehow the recursive function worked its way through the Object into some Ember Framework code and deleted functions from the Ember Framework during runtime .
ComputedPropertyPrototype.volatile()
ComputedPropertyPrototype.property()
exports.default.mixin.Mixin.create.clear()
exports.default.mixin.Mixin.create.popObject()
exports.default.mixin.Mixin.create.shiftObject()
...
Therefore I got these weird sounding errors and difficult to debug errors, as the deletion of the property happens before it actually causes an error.
It was my bad with the hacky serializer, but I hope this helps some of you when stumbling upon the same error.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.