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 problem with various methods from ArrayProxy #263

Merged
merged 1 commit into from
Jan 7, 2019

Conversation

synaptiko
Copy link
Contributor

In my case I had following code:

model = EmberObject.create({
  items: findPaged({ ... })
})

...

savedItems: filterBy('items', 'isNew', false)

And it was failing whenever I accessed savedItems.

ArrayProxy implementation changed in Ember 3.x, now it's required to
call this._super(...arguments) in init method so the ArrayProxy is
properly initialized.

It fixes issues like this:

Uncaught TypeError: Cannot set property 'length' of undefined
    at Class.objectAt (array_proxy.js:131)
    at objectAt (ember-metal.js:1436)
    at Class._emberMetal.Mixin.create._Mixin$create.slice (array.js:230)
    at Class.objsForPage (divide-into-pages.js:11)
    at Class.<anonymous> (paged-array.js:19)
    at ComputedProperty.get (ember-metal.js:2515)
    at _get (ember-metal.js:1356)
    at Class._addArrangedContentArrayObsever (array_proxy.js:164)
    at Class.init (array_proxy.js:102)
    at Class.CoreObject (core_object.js:145)

Fixes #258

@broerse
Copy link
Collaborator

broerse commented Jan 5, 2019

Like this but this generates 8 failed test. Can you take a look?

ArrayProxy implementation changed in Ember 3.x, now it's required to
call this._super(...arguments) in init method so the ArrayProxy is
properly initialized.

It fixes issues like this:
Uncaught TypeError: Cannot set property 'length' of undefined
    at Class.objectAt (array_proxy.js:131)
    at objectAt (ember-metal.js:1436)
    at Class._emberMetal.Mixin.create._Mixin$create.slice (array.js:230)
    at Class.objsForPage (divide-into-pages.js:11)
    at Class.<anonymous> (paged-array.js:19)
    at ComputedProperty.get (ember-metal.js:2515)
    at _get (ember-metal.js:1356)
    at Class._addArrangedContentArrayObsever (array_proxy.js:164)
    at Class.init (array_proxy.js:102)
    at Class.CoreObject (core_object.js:145)
@synaptiko
Copy link
Contributor Author

Fixed according to docs: https://github.com/emberjs/ember.js/blob/v3.6.1/packages/%40ember/-internals/runtime/lib/system/array_proxy.js#L62-L64

When overriding this class, it is important to place the call to _super after setting content so the internal observers have a chance to fire properly

@broerse broerse merged commit ac40fff into mharris717:master Jan 7, 2019
@broerse
Copy link
Collaborator

broerse commented Jan 7, 2019

Thanks! https://github.com/mharris717/ember-cli-pagination/releases/tag/v3.1.4

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.

Uncaught TypeError: Cannot set property 'length' of undefined
2 participants