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

List.js scope conext for sort handler is missing #4241

Closed
jcyuan opened this issue Dec 17, 2018 · 2 comments
Closed

List.js scope conext for sort handler is missing #4241

jcyuan opened this issue Dec 17, 2018 · 2 comments

Comments

@jcyuan
Copy link
Contributor

jcyuan commented Dec 17, 2018

Phaser Version: v3.5.1, Phaser.Structs.List.js

sort: function (property)
{
    if (property)
    {
        this._sortKey = property;

        StableSort.inplace(this.list, this.sortHandler);
    }

    return this;
},
sortHandler: function (childA, childB)
{
    return childA[this._sortKey] - childB[this._sortKey];
},

as you can see, here it passes this.sortHandler to the StableSort.inplace function, but when later this handler is executed by the StableSort, the _sortKey is lost in the scope because this is pointed to the Window object.

@jcyuan
Copy link
Contributor Author

jcyuan commented Dec 17, 2018

btw, I think better to have an optional paramter customizedHandler for complex object sorting.

@photonstorm
Copy link
Collaborator

Thank you for submitting this issue. We have fixed this and the fix has been pushed to the master branch. It will be part of the next release. If you get time to build and test it for yourself we would appreciate that.

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

No branches or pull requests

2 participants