shawnbot / aight

JavaScript shims and shams for making IE8-9 behave reasonably

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Test for getComputedStyle is broken in browsers that implement the current Web IDL specification

bzbarsky opened this issue · comments

This test in computed-style.js:

'getComputedStyle' in Window.prototype

is broken in browsers that implement the current Web IDL specification for Window (e.g. Firefox 32), because per that specification the property lives on the window object directly, not on the prototype.

The right test is:

'getComputedStyle' in window

which should work in both browsers that put the property on the window directly and ones that put it on the prototype.

This issue causes aight to try to use the IE-only .currentStyle in Firefox 32, which of course doesn't work very well.

I believe that this is addressed in the v2 refactor (#38), which incorporates more rigorously tested polyfills, including window.getComputedStyle. Thanks for reporting. I'll keep this open until I've confirmed that it's fixed in v2.

Paging @WebReflection: I think this is your issue, since ie8 shims getComputedStyle via window.Window.prototype.

why is ie8 even offered to Firefox when the only right way to include it would be

<!--[if IE 8]><script src="ie8.js"></script><![endif]-->

or via CDN

<!--[if IE 8]><script
  src="//cdnjs.cloudflare.com/ajax/libs/ie8/0.2.2/ie8.js"
></script><![endif]-->

ie8 aim is to fix IE8, not Firefox … it is not there to feature detect anything else that is not IE8 … I am not sure once getComputedStyle gets fixed the rest would work.

OK, just to be clear, this has nothing to do with ie8, this is the first line of this file:
https://github.com/shawnbot/aight/blob/master/js/computed-style.js

and I think it should be !('getComputedStyle' in window) indeed

ie8 has nothing to do with this test but yes, it will patch for IE8 only 'getComputedStyle too.

Sorry, I should have been clear that this relates to #38. An IE conditional comment is the suggested usage, but I would prefer that aight not interfere with modern browsers even if it is included (for instance, so that users can test flags such as aight.browser.ie). I'm happy to just wrap the included ie8 code in an if statement if this complicates matters.

ie8 first line is if(document.craeteEvent) return; so there's no way it can interfere with anything else and all browsers since ever, but IE < 9, has that in ;-)

I've shown you where is the problem and it's not in ie8 but I wanted to underline that you don't need to serve ie8.js to any browser that is not IE8 and conditional comments never interfered with anything but older IEs.

Last, you cannot test IE8 via any other browser different from real IE8 (tests fails in emulators, as examples, but pass as expected in real IE8) so you are free to aight.browser.ie but that won't produce any predictable or expected result in other browsers. Just as extra warning.

If there's anything else I can do please let me know, again I just wanted to clarify some possible misunderstanding.

Cheers

Sorry for the confusion, @WebReflection. This will be fixed in #38.

Fixed in #38!