jeudi 4 juin 2015

ember-cli "TypeError: desc.get is not a function" after upgrade of ember-cli

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 descwas 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




Aucun commentaire:

Enregistrer un commentaire