Skip to content

Conversation

@bmomberger-bitovi
Copy link
Contributor

Before this PR, patches events were being dispatched with the data being added into the array pre-conversion. So if the observable array has static get items() defined, it will correctly push converted items into the array, but dispatch a patch with the original objects instead.

Because can-view-live uses the data in patches to keep list items in sync, this was causing issues with live binding.

This PR converts items to be added into the array in the mutation method shim, a pull up from the handlers for each individual array method, and now at the same level where the patches dispatch is being ordered. This ensures that any patch listener has the same data as the array itself.

Copy link
Contributor

@phillipskevin phillipskevin left a comment

Choose a reason for hiding this comment

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

assert.ok(arr[0] instanceof MyObject, "Converts on an index setter");
});

QUnit.test("patches dispatched with converted members", function (assert) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we still need this test?

Copy link
Member

Choose a reason for hiding this comment

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

Oh it seems not :/

Copy link
Member

Choose a reason for hiding this comment

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

I removed them.

Copy link
Contributor

Choose a reason for hiding this comment

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

I liked the other test 😢

@bmomberger-bitovi bmomberger-bitovi merged commit de267ba into master Nov 19, 2019
@bmomberger-bitovi bmomberger-bitovi deleted the convert-patch-inserts branch November 19, 2019 17:18
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.

4 participants