Skip to content

Wrong behaviour resetting collection without models array #38

@mogarick

Description

@mogarick

Calling collection.reset() without arguments causes a wrong behaviour due to line 588 of query-engine.js. (QueryCollection.prototype.add). It looks the problem is the condition that forces the creation of an array when models argument is not one (:[models]). It creates an array even in the case the models argument of add method is undefined. This causes the array to have 1 phantom element ({}).
Fortunately there is an easy workaround, to call reset method with an an empty array (collection.reset([])). This way the condition that gets evaluated is ?models.slice() and that returns an empty array which is the expected behaviour.

Are you accepting pull requests? I see many issues open.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions