Skip to content

Commit

Permalink
fix: remove workaround for handling undefined
Browse files Browse the repository at this point in the history
This workaround was added to handle an issue in `Ember.set`

poteto#14

This original problem has long been resolved in Ember. _Not_ calling
`set` now causes some issues with Ember 3.13+, as properties on the
original object either need to be `@tracked` _or_ be updated using
`set`, the later of which makes more sense.
  • Loading branch information
alexlafroscia committed Jun 16, 2020
1 parent 3a8b930 commit 2395a0f
Showing 1 changed file with 1 addition and 18 deletions.
19 changes: 1 addition & 18 deletions addon/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,7 @@ export default function deepSet(obj, key, value) {
allKeys[i + 1] && isObject(currentValue) ? currentValue :
allKeys[i + 1] && !isObject(currentValue) ? {} :
value;
if (valueToSet === undefined) {
// ember's set method does not handle undefined values correctly in older versions
// https://github.com/emberjs/ember.js/issues/14270
if (
acc.hasOwnProperty(currentKey) ||
typeof acc.setUnknownProperty !== 'function'
) {
acc[currentKey] = valueToSet;
if (typeof acc.notifyPropertyChange === 'function') {
acc.notifyPropertyChange(currentKey);
}
} else {
acc.setUnknownProperty(currentKey, valueToSet);
}
return valueToSet;
} else {
return set(acc, currentKey, valueToSet);
}
return set(acc, currentKey, valueToSet);
}, obj);
return value;
}

0 comments on commit 2395a0f

Please sign in to comment.