classList.js icon indicating copy to clipboard operation
classList.js copied to clipboard

Doesn't work in IE 8.0.7601.17514 / Win 7

Open johngeorgewright opened this issue 10 years ago • 11 comments

I've just tried your polyfill in the above version and it doesn't work. It fails here: https://github.com/eligrey/classList.js/blob/master/classList.js#L174

Turns out the exception thrown isn't what you were expecting. The exception has no number property. It is a TypeError stating that "getters & setters can not be defined on this javascript engine".

Removing the condition if (ex.number === -0x7FF5EC54) { ... fixes the problem.

johngeorgewright avatar Feb 11 '15 12:02 johngeorgewright

Hmm, odd. I will need to investigate further before removing the condition, but thanks for informing me. Years ago when I first made classList.js, that condition was working fine in IE8. Maybe a security patch changed something.

eligrey avatar Feb 11 '15 16:02 eligrey

Agreed, having a condition there is probably a good idea. There may be some other kind of duck typing you can check on the error.

johngeorgewright avatar Feb 11 '15 20:02 johngeorgewright

I can also confirm this issue. ex.number results to undefined in IE11's compatibility mode for IE8. Removing the condition seems to solve it.

pkese avatar Mar 02 '15 23:03 pkese

:+1: Tested in IE8 with XP VM and this is still a problem. The solution proposed works great.

IE v8.0.6001.18702
Update Versions: 0

MadLittleMods avatar Oct 02 '15 15:10 MadLittleMods

How can you replicate the problem? I have the same IE8 version in a Windows XP VM and I don't have this issue.

nbouvrette avatar Dec 30 '15 02:12 nbouvrette

Windows XP VM from Microsoft running in VirtualBox on a host Macbook.

I use it via require/import it in a browserify/webpack bundle with babel transpiling

MadLittleMods avatar Dec 30 '15 02:12 MadLittleMods

I'm running my Windows XP VM (32 bits) in a Virtual Box hosted on a Windows 7 VM (64 bits).

First time I hear about transpiling. I simply load classList.js in my <head> and it has been working well so far.

nbouvrette avatar Dec 30 '15 02:12 nbouvrette

What you had hold of initially was an ActiveX exception (the number is an HRESULT). Clearly IE 11 is no longer using ActiveX objects behind the scenes.

Might as well remove the check as it simply causes all other exceptions to fail silently. There's really no way to deal with the exception anyway. What's the point of having it enumerable in some browsers and not in others?

Realize this will never be a perfect imitation of classList. It's simply an impossible task; for one, the array-like object returned is not live. Then there's the unsolvable IE 8- issue at hand.

A "polyfill" that doesn't actually work as expected only serves to deceive other scripts. It fools their feature detection into thinking that the feature is there, but it's really just an incomplete imposter.

In general, DOM "polyfills" are highly ill-advised and this one is a good example of why. Better to write wrappers (e.g. hasClass, addClass, etc.)

Also note that transpiling is just a red herring here.

HTH

david-mark avatar Jan 12 '17 07:01 david-mark

I'm super busy with my proprietary stuff and missed this a year ago. I merged #43 just now.

I'm sorry about this issue affecting any of you. Please tell me if the changes I have merged have fixed this issue for you.

eligrey avatar Jan 12 '17 09:01 eligrey

@eligrey Could you please update the classList.js on the CloudFlare CDN and post the updated URL's in the readme.md?

Finesse avatar Apr 20 '17 03:04 Finesse

I use this commit https://github.com/beck/classlist-polyfill/commit/d94a623c25bc69caf09f7089c0066fd65e760e82 but it seems ie11 wont support multiple args. So I have to write:

e.classList.add(a);
e.classList.add(b);

englishextra avatar Apr 20 '17 05:04 englishextra