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 variable check for non-null & clean up #3559

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from

Conversation

PimsJay01
Copy link

I use function getTileAt of TMXLayer who accept as parameter a cc.Point or 2 integers. I found a bug present in almost every getters of class TMXLayer. If two integers are passed to function and x is equal to 0, function throw error "cc.TMXLayer.getTileAt(): pos should be non-null". Indeed, function to filter value was :

getTileAt: function (pos, y) {
    if (!pos) {
        throw new Error("cc.TMXLayer.getTileAt(): pos should be non-null");
    }
    ...
}

this check return true if :

  • null
  • undefined
  • NaN
  • empty string ("")
  • 0
  • false

I suppose that only null or undefined values have to throw error. So I suggest to change check as if(pos == null)

I also took the liberty to change every if(pos === undefined) by if(pos == null) to filter undefined and null values.

Is there any test for this class ?

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.

1 participant