Using 1.7 release I found I had to modify the parseInt call slightly to:
Code: Select allparseInt(layer.bounds.toString().replace(/\D/g,""),10)
In my case a layer with the bounds 0 px, 0 px, 900 px, 900 px was returning as empty since parseInt("00900900") returns 0.
Issue in Stdlib.isLayerEmpty
Issue in Stdlib.isLayerEmpty
That's why I hate using parseInt; if the first character is '0' it assumes the number is octal so it stops parsing when it hits the first '9'.
Here are two other ways of tackling the problem. I'll change stdlib.js to use one of them.
Code: Select all return Number(layer.bounds.toString().replace(/\D/g,"")) == 0;
return layer.bounds.toString().replace(/\D|0/g,"") == '';
Thanks for finding this.
-X
Here are two other ways of tackling the problem. I'll change stdlib.js to use one of them.
Code: Select all return Number(layer.bounds.toString().replace(/\D/g,"")) == 0;
return layer.bounds.toString().replace(/\D|0/g,"") == '';
Thanks for finding this.
-X
Issue in Stdlib.isLayerEmpty
For what it's worth, I like myranalis' fix the best.
Both parseInt and Number can default to an unexpected base. At least with parseInt you can specify that you want it to convert to base 10.
Both parseInt and Number can default to an unexpected base. At least with parseInt you can specify that you want it to convert to base 10.