mharris717 / ember-cli-pagination

Pagination Addon for Ember CLI
MIT License
273 stars 116 forks source link

Instances of `page-numbers` trigger errors with certain attribute orders #242

Open jasonmevans opened 6 years ago

jasonmevans commented 6 years ago

I discovered this issue just now while implementing pagination in my project. The underlying stack trace and error messaging surrounding the issue were not clear, so I did a bit of digging into the ember source code. It seems that the way this project requires properties to be passed into the page-numbers component causes an exception when content does not come first.

https://github.com/mharris717/ember-cli-pagination/blob/9f43e32c14f024fac6d7aab45f51f651cc61e5b4/addon/components/page-numbers.js#L9

The reason being that on this line the currentPage property is a bound alias to content.page. Now, if currentPage comes before content you will receive a console error saying, "Property set failed: object in path "content" could not be found or was destroyed."

{{page-numbers currentPage=page content=results }}

screen shot 2018-03-13 at 4 51 58 pm

If the order is changed to this then the error will be resolved:

{{page-numbers content=results currentPage=page }}
Redsandro commented 4 years ago

I'm experiencing the same, and similar issues the other way around.

Is there a similar ember-cli module that works with property names as used in the JSON:API documentation for pagination? I'm having to do a lot of guesswork for undocumented things (such as nested properties), so I would rather try something that works with zero configuration.