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

[BUGFIX beta] property_set should reuse reference to its meta #15210

Merged
merged 4 commits into from
May 5, 2017
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
4 changes: 2 additions & 2 deletions packages/ember-metal/lib/computed.js
Original file line number Diff line number Diff line change
Expand Up @@ -412,7 +412,7 @@ ComputedPropertyPrototype._set = function computedPropertySet(obj, keyName, valu
return ret;
}

propertyWillChange(obj, keyName);
propertyWillChange(obj, keyName, meta);

if (hadCachedValue) {
cache[keyName] = undefined;
Expand All @@ -428,7 +428,7 @@ ComputedPropertyPrototype._set = function computedPropertySet(obj, keyName, valu
cache[keyName] = ret;
}

propertyDidChange(obj, keyName);
propertyDidChange(obj, keyName, meta);

return ret;
};
Expand Down
4 changes: 2 additions & 2 deletions packages/ember-metal/lib/property_set.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,15 @@ export function set(obj, keyName, value, tolerant) {
} else if (currentValue === value) { /* no change */
return value;
} else {
propertyWillChange(obj, keyName);
propertyWillChange(obj, keyName, meta);

if (MANDATORY_SETTER) {
setWithMandatorySetter(meta, obj, keyName, value);
} else {
obj[keyName] = value;
}

propertyDidChange(obj, keyName);
propertyDidChange(obj, keyName, meta);
}

return value;
Expand Down
16 changes: 10 additions & 6 deletions packages/ember-runtime/lib/mixins/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,13 @@ export function arrayContentDidChange(array, startIdx, removeAmt, addAmt) {
if (cache) {
if (cache.firstObject !== undefined &&
objectAt(array, 0) !== cacheFor.get(cache, 'firstObject')) {
propertyWillChange(array, 'firstObject');
propertyDidChange(array, 'firstObject');
propertyWillChange(array, 'firstObject', meta);
propertyDidChange(array, 'firstObject', meta);
}
if (cache.lastObject !== undefined &&
objectAt(array, get(array, 'length') - 1) !== cacheFor.get(cache, 'lastObject')) {
propertyWillChange(array, 'lastObject');
propertyDidChange(array, 'lastObject');
propertyWillChange(array, 'lastObject', meta);
propertyDidChange(array, 'lastObject', meta);
}
}
return array;
Expand Down Expand Up @@ -653,22 +653,26 @@ EachProxy.prototype = {
arrayWillChange(content, idx, removedCnt, addedCnt) {
let keys = this._keys;
let lim = removedCnt > 0 ? idx + removedCnt : -1;
let meta;
for (let key in keys) {
meta = meta || peekMeta(this);
if (lim > 0) {
removeObserverForContentKey(content, key, this, idx, lim);
}
propertyWillChange(this, key);
propertyWillChange(this, key, meta);
}
},

arrayDidChange(content, idx, removedCnt, addedCnt) {
let keys = this._keys;
let lim = addedCnt > 0 ? idx + addedCnt : -1;
let meta;
for (let key in keys) {
meta = meta || peekMeta(this);
if (lim > 0) {
addObserverForContentKey(content, key, this, idx, lim);
}
propertyDidChange(this, key);
propertyDidChange(this, key, meta);
}
},

Expand Down