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

Fix mutation after push #81

Merged
merged 2 commits into from
May 22, 2020
Merged

Fix mutation after push #81

merged 2 commits into from
May 22, 2020

Conversation

cherifGsoul
Copy link
Member

@cherifGsoul cherifGsoul commented May 20, 2020

Fix the item mutation with array mutation methods like push:

const myList = new ObservableArray([0,1]);
myList.push("I am going to hide some changes.");
		
canReflect.onPatches(myList, function (patches) {
    console.log(patches[0].insert[0]);   // -> 'Patched after push'
});
	
myList[1] = "Patched after push";

Closes #82

@@ -580,7 +580,7 @@ module.exports = function() {
});

QUnit.test("value, oldValue, action, key on event object", function(assert) {
assert.expect(22);
assert.expect(26);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@cherifGsoul can you explain why there are more assertions now?

@@ -43,7 +43,8 @@ class ObservableArray extends MixedInArray {

mixins.finalizeClass(new.target);
mixins.initialize(this, props || {});

this[metaSymbol].preventSideEffects = 0;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, do you know why this property is not initialized? It looks like it should be here:

preventSideEffects: 0
.

@cherifGsoul cherifGsoul merged commit bf070db into master May 22, 2020
@cherifGsoul cherifGsoul deleted the fix-mutating-with-push branch May 22, 2020 20:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Patches are not dispatched after mutation methods usage
2 participants