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

Make dependencies that end in @each expand to []. #12848

Merged
merged 1 commit into from
Jan 20, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions packages/ember-metal/lib/computed.js
Original file line number Diff line number Diff line change
Expand Up @@ -252,11 +252,6 @@ ComputedPropertyPrototype.property = function() {
var args;

var addArg = function(property) {
assert(
`Depending on arrays using a dependent key ending with \`@each\` is no longer supported. ` +
`Please refactor from \`Ember.computed('${property}', function() {});\` to \`Ember.computed('${property.slice(0, -6)}.[]', function() {})\`.`,
property.slice(-5) !== '@each'
);
args.push(property);
};

Expand Down
6 changes: 4 additions & 2 deletions packages/ember-metal/lib/expand_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import EmberError from 'ember-metal/error';

var SPLIT_REGEX = /\{|\}/;

var END_WITH_EACH_REGEX = /\.@each$/;

/**
Expands `pattern`, invoking `callback` for each expansion.

Expand Down Expand Up @@ -50,10 +52,10 @@ export default function expandProperties(pattern, callback) {
});

properties.forEach((property) => {
callback(property.join(''));
callback(property.join('').replace(END_WITH_EACH_REGEX, '.[]'));
});
} else {
callback(pattern);
callback(pattern.replace(END_WITH_EACH_REGEX, '.[]'));
}
}

Expand Down
6 changes: 0 additions & 6 deletions packages/ember-metal/lib/mixin.js
Original file line number Diff line number Diff line change
Expand Up @@ -750,12 +750,6 @@ export function observer(...args) {
var paths;

var addWatchedProperty = function(path) {
assert(
`Depending on arrays using a dependent key ending with \`@each\` is no longer supported. ` +
`Please refactor from \`Ember.observer('${path}', function() {});\` to \`Ember.observer('${path.slice(0, -6)}.[]', function() {})\`.`,
path.slice(-5) !== '@each'
);

paths.push(path);
};
var _paths = args.slice(0, -1);
Expand Down
14 changes: 7 additions & 7 deletions packages/ember-metal/tests/computed_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,14 @@ QUnit.test('defining computed property should invoke property on set', function(
equal(get(obj, 'foo'), 'computed bar', 'should return new value');
});

QUnit.test('defining a computed property with a dependent key ending with @each is deprecated', function() {
expectAssertion(function() {
computed('blazo.@each', function() { });
}, `Depending on arrays using a dependent key ending with \`@each\` is no longer supported. Please refactor from \`Ember.computed('blazo.@each', function() {});\` to \`Ember.computed('blazo.[]', function() {})\`.`);
QUnit.test('defining a computed property with a dependent key ending with @each is expanded to []', function() {
var cp = computed('blazo.@each', function() { });

expectAssertion(function() {
computed('qux', 'zoopa.@each', function() { });
}, `Depending on arrays using a dependent key ending with \`@each\` is no longer supported. Please refactor from \`Ember.computed('zoopa.@each', function() {});\` to \`Ember.computed('zoopa.[]', function() {})\`.`);
deepEqual(cp._dependentKeys, ['blazo.[]']);

cp = computed('qux', 'zoopa.@each', function() { });

deepEqual(cp._dependentKeys, ['qux', 'zoopa.[]']);
});

var objA, objB;
Expand Down