You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[BUGFIX beta] Prevent errors when using const (get arr 1).
Prior to this change, calling `{{get arr 1}}` would throw an error:
```
pathReference.value(...).split is not a function
```
This commit fixes that, by only attempting to `.split` when the
underlying value is not actually a string.
`Ember.get` / `Ember.set` are also updated to allow `get(obj, 2)`
(previously allowed only string keys).
Copy file name to clipboardExpand all lines: packages/ember-metal/lib/property_get.js
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -72,8 +72,8 @@ export function getPossibleMandatoryProxyValue(obj, keyName) {
72
72
exportfunctionget(obj,keyName){
73
73
assert(`Get must be called with two arguments; an object and a property key`,arguments.length===2);
74
74
assert(`Cannot call get with '${keyName}' on an undefined object.`,obj!==undefined&&obj!==null);
75
-
assert(`The key provided to get must be a string, you passed ${keyName}`,typeofkeyName==='string');
76
-
assert(`'this' in paths is not supported`,keyName.lastIndexOf('this.',0)!==0);
75
+
assert(`The key provided to get must be a string or number, you passed ${keyName}`,typeofkeyName==='string'||(typeofkeyName==='number'&&!isNaN(keyName)));
76
+
assert(`'this' in paths is not supported`,typeofkeyName!=='string'||keyName.lastIndexOf('this.',0)!==0);
77
77
assert('Cannot call `get` with an empty string',keyName!=='');
assert(`Cannot call set with '${keyName}' on an undefined object.`,obj&&typeofobj==='object'||typeofobj==='function');
48
-
assert(`The key provided to set must be a string, you passed ${keyName}`,typeofkeyName==='string');
49
-
assert(`'this' in paths is not supported`,keyName.lastIndexOf('this.',0)!==0);
48
+
assert(`The key provided to set must be a string or number, you passed ${keyName}`,typeofkeyName==='string'||(typeofkeyName==='number'&&!isNaN(keyName)));
49
+
assert(`'this' in paths is not supported`,typeofkeyName!=='string'||keyName.lastIndexOf('this.',0)!==0);
50
50
assert(`calling set on destroyed object: ${toString(obj)}.${keyName} = ${toString(value)}`,!obj.isDestroyed);
0 commit comments