pixijs / layers

Separate the z-hierarchy of your scene tree from its canonical structure.
https://pixijs.io/layers/docs/
MIT License
222 stars 57 forks source link

Don't try to call methods on an undefined group #33

Closed ArvinJA closed 5 years ago

ArvinJA commented 6 years ago

Remember that both "null" and "undefined" exist, I get why one would want to do extra strict comparisons, but in this particular case, we don't want to call methods on an undefined object (I ran into this problem).

ivanpopelyshev commented 6 years ago

I dont know what to do with that, people just keep assigning undefined in fields. If you assign undefined in numberic fields you'll get NaN , not 0 . Here is the same problem.

I dont know whether to accept it or to add one "console.log" that tells people not to do that.

ArvinJA commented 6 years ago

In my case I didn't define anything as "undefined", but "group" happened to be undefined. I think it won't hurt to be able to handle all sorts of "not set" cases, not just null.

ivanpopelyshev commented 6 years ago

It cant happen, i put null in DisplayObject prototype. I'll accept this PR nevertheless because its not the first time people do that.

ArvinJA commented 6 years ago

"It can't happen" is a pretty strong statement when it comes to code. I didn't have that many moving parts, I never defined anything as undefined myself. Yet, I ended up with an undefined value. You can of course choose to not believe me, I am just saying what happened for me and why. ¯_(ツ)_/¯

Hopefully this patch solves the same problem for someone else

ivanpopelyshev commented 5 years ago

I think I merged it yesterday.,.. Sorry for snail speed ;)