jonathantneal / flexibility

A JavaScript polyfill for Flexbox

Home Page:https://jonathantneal.github.io/flexibility/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Uncaught TypeError: document.attachEvent is not a function

hendrathings opened this issue · comments

I use this plugin and get this error Uncaught TypeError: document.attachEvent is not a function in chrome and edge browser. Does any plugin missing here?

I am getting this error message as well in Chrome. in Firefox, I get the following message:

TypeError: document.attachEvent is not a function
...n!1}},(!flexibility.detect()||t()<=9)&&document.attachEvent("onreadystatechange"...

@mastastealth have you try it in ie? version 8 - edge? is it work for you?

There's no need to load this file in non-IE browsers

The issue is in this line here https://github.com/10up/flexibility/blob/master/lib/detect.js#L21 because ieVersion() returns false in non-IE browsers, and false <= 9 evaluates to true

@wyattdanger It'd be helpful to have this noted very strongly in the readme.

commented

The fix is good to have 👍

It would be nice to have a conditional comment version in the readme. It's a bandwith/connection saver.

<!--[if lte IE 9]>
  <script src="flexibility.js"></script>
<![endif]-->

The conditional comment needs to be

<!--[if lt IE 10]>
  <script src="flexibility.js"></script>
<![endif]-->

Flexbox doesn't work in IE9 so it needs to be loaded there as well. Or it could even just be this since conditional comments don't work in IE 10

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

@Dan503 The original conditional works as well. if lte IE 9 means "less than or EQUAL to IE9" which is the same as if lt IE 10

Oh I didn't spot the "e". Ok yeah, yours works as well and is probably the better one to go with.

There are no events firing in v2, so this should no longer be an issue.