Skip to content

Commit

Permalink
Use specific messages for specific reasons the expansion stopped working
Browse files Browse the repository at this point in the history
  • Loading branch information
Serabe committed May 8, 2017
1 parent 9c00ab2 commit d9217ed
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 7 deletions.
23 changes: 17 additions & 6 deletions packages/ember-metal/lib/expand_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,7 @@ export default function expandProperties(pattern, callback) {
})(pattern));

warn(
`You used the key "${pattern}" which is invalid and is not longer expanding on Ember 2.13.`,
((str) => {
...((str, opts) => {
let inBrace = 0;
let char;
for (let i = 0; i < str.length; i++) {
Expand All @@ -76,16 +75,28 @@ export default function expandProperties(pattern, callback) {
} else if (char === '}') {
inBrace--;
} else if (char === ',' && inBrace === 0) {
return false;
return [
`You are using a comma outside braces in ${str} that was unintentionally being expanded. This property will no longer expand on Ember 2.13.`,
false,
opts
];
}

if (inBrace > 1 || inBrace < 0) {
return false;
return [
`You have nested or unbalanced properties in ${str} that was unintentionally being expanded. This property will no longer expand on Ember 2.13.`,
false,
opts
];
}
}

return inBrace === 0;
})(pattern), { id: 'ember-metal.invalid-expand-properties' });
return [
`The property ${str} ended with unbalanced braces. This property will no longer expand on Ember 2.13.`,
inBrace === 0,
opts
];
})(pattern, { id: 'ember-metal.invalid-expand-properties' }));

let parts = pattern.split(SPLIT_REGEX);
let properties = [parts];
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-metal/tests/expand_properties_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ QUnit.test('unbalanced braces are warned', function() {
invalidBraceProperties.forEach((invalidProperties) =>
expectWarning(() => {
expandProperties(invalidProperties, addProperty)
}, / which is invalid and is not longer expanding on Ember 2\.13\./)
}, / no longer expand on Ember 2\.13\./)
);
});

Expand Down

0 comments on commit d9217ed

Please sign in to comment.