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

@computed isn't converted to a computed property? #17

Closed
devinus opened this issue May 8, 2015 · 4 comments
Closed

@computed isn't converted to a computed property? #17

devinus opened this issue May 8, 2015 · 4 comments

Comments

@devinus
Copy link

devinus commented May 8, 2015

With this code using the latest released ember-cli (0.2.3):

import Ember from 'ember';
import computed from 'ember-computed-decorators'; // jshint ignore:line

export default Ember.Component.extend({
  items: null,
  currentPath: null,

  /* jshint ignore:start */
  @computed('items', 'currentPath')
  /* jshint ignore:end */
  breadCrumbs(items, currentPath) {
    let linkable = true;
    return Ember.A(items).map((item) => {
      const { label, path } = item;
      const active = path === currentPath;
      linkable = linkable && !active;
      return { label, path, active, linkable };
    });
  }
});

I'm getting this error when trying to use breadCrumbs in an #each:

Uncaught Error: Assertion Failed: The value that #each loops over must be an Array. You passed function (items, currentPath) {
        var linkable = true;
        return Ember['default'].A(items).map(function (item) {
          var label = item.label;
          var path = item.path;

          var active = path === currentPath;
          linkable = linkable && !active;
          return { label: label, path: path, active: active, linkable: linkable };
        });
      }

It's almost as if the transformation isn't being run? However, I do have the es7.decorsators optional transform enabled.

@devinus
Copy link
Author

devinus commented May 8, 2015

This is what the transpiled code looks like:

define('rebelmail-campaign-manager/pods/components/bread-crumbs/component', ['exports', 'ember', 'ember-computed-decorators'], function (exports, Ember, computed) {

  'use strict';

  function _createDecoratedObject(descriptors) { var target = {}; for (var i = 0; i < descriptors.length; i++) { var descriptor = descriptors[i]; var decorators = descriptor.decorators; var key = descriptor.key; delete descriptor.key; delete descriptor.decorators; descriptor.enumerable = true; descriptor.configurable = true; descriptor.writable = true; if (decorators) { for (var f = 0; f < decorators.length; f++) { var decorator = decorators[f]; if (typeof decorator === 'function') { descriptor = decorator(target, key, descriptor) || descriptor; } else { throw new TypeError('The decorator for method ' + descriptor.key + ' is of the invalid type ' + typeof decorator); } } } if (descriptor.initializer) { descriptor.value = descriptor.initializer.call(target); Object.defineProperty(target, key, descriptor); } } return target; }

  exports['default'] = Ember['default'].Component.extend(_createDecoratedObject([{
    key: 'items',
    initializer: function initializer() {
      return null;
    }
  }, {
    key: 'currentPath',
    initializer: function initializer() {
      return null;
    }
  }, {
    key: 'breadCrumbs',
    decorators: [computed['default']('items', 'currentPath')],

    /* jshint ignore:end */
    initializer: function initializer() {
      return function (items, currentPath) {
        var linkable = true;
        return Ember['default'].A(items).map(function (item) {
          var label = item.label;
          var path = item.path;

          var active = path === currentPath;
          linkable = linkable && !active;
          return { label: label, path: path, active: active, linkable: linkable };
        });
      };
    }
  }]));

  /* jshint ignore:start */

});

@stefanpenner
Copy link
Contributor

ah, i think #master works correctly, but we are pending a release. Can you try master?

@devinus
Copy link
Author

devinus commented May 8, 2015

Sweet, 0.1.3 works!

@devinus devinus closed this as completed May 8, 2015
@stefanpenner
Copy link
Contributor

👍

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

No branches or pull requests

2 participants