chrislondon / 9-Patch-Image-for-Websites

UNMAINTAINED -- Javascript file to allow 9 patch images on the web. For a more detailed explanation of 9-patch images read here: http://developer.android.com/guide/topics/graphics/2d-graphics.html#nine-patch
88 stars 30 forks source link

If a html file has a canvas element, you will get an error. #19

Closed vfan closed 7 years ago

vfan commented 8 years ago

Uncaught TypeError: Failed to execute 'getComputedStyle' on 'Window': parameter 1 is not of type 'Element'. in function NinePatchGetStyle, you may need to add try catch.. var computedStyle = window.getComputedStyle(element, "");

Demian87 commented 7 years ago

I have the same issue. Do you have any ideas, how to fix it?

rpendleton commented 7 years ago

I'm not sure if this was the source of the original issue, but it appears the example was encountering this error due to the use of a for...in loop over an HTMLContainer. I've pushed a commit that should fix that along with a few other issues.

I also experimented with adding a canvas element to the document and didn't see any problems, so I'm going to assume the for...in loop was the cause of the original issue as well.

Demian87 commented 7 years ago

That helped! Thanks!