Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No normalization of add/remove/toggle in IE10 and IE11 #44

Open
PatrickEickmeier opened this issue Dec 11, 2015 · 17 comments
Open

No normalization of add/remove/toggle in IE10 and IE11 #44

PatrickEickmeier opened this issue Dec 11, 2015 · 17 comments

Comments

@PatrickEickmeier
Copy link

I tested the polyfill in IE10 and IE11 (Win7 on a virtual machine) and the functions still have partial support of classList. Multiple parameters in the add() and remove() functions still don't work.

    if (!("classList" in document.createElement("_"))
        || document.createElementNS && !("classList" in document.createElementNS("http://www.w3.org/2000/svg", "g"))) {

The last condition !("classList" in document.createElementNS("http://www.w3.org/2000/svg", "g")) evaluates to true, so the part for no classlist support will be executed.
The part for partial classlist supported browsers won't be executed in IE10/11.

I could "fix" the issue by changing || to && in line18/19:

    if (!("classList" in document.createElement("_"))
        && document.createElementNS && !("classList" in document.createElementNS("http://www.w3.org/2000/svg", "g"))) {

It seems to work for IE10/11, but don't know if is could be an issue for other browsers.

@Rendez
Copy link

Rendez commented Dec 17, 2015

+1 having the same issue here.

@dgraham
Copy link

dgraham commented Feb 13, 2016

This regression was introduced by 6379aea in #40.

@Tokimon
Copy link

Tokimon commented May 10, 2016

+1 on this. Having the same issue.

@stevenvachon
Copy link

@eligrey hello?

@tremby
Copy link

tremby commented Jun 30, 2016

The suggested fix here breaks SVG support in IE11.

@Vestride
Copy link

@tbranyen would you mind publishing and older version of this package on npm? Right now the only release on npm contains this bug. You could check out the 2014-12-13 tag and publish it as 1.1.20141213, which won't break semver. Here's an example in a stackoverflow answer you can follow to publish an older version.

@drgullin
Copy link

What about simplification? We may just use:

if (!("classList" in document.createElement("_"))) {

So the normalization would also work as expected.

@tremby
Copy link

tremby commented Jul 28, 2016

Does that detect also whether support exists for SVG elements?

@stevenvachon
Copy link

@eligrey are you deceased?

@stevenvachon
Copy link

@PatAtMacadamian comments?

@stevenvachon
Copy link

For anyone needing this, I have a pull request in, but since that will probably never get merged, you can point to my branch in your projects: https://github.com/stevenvachon/classList.js

@drgullin
Copy link

drgullin commented Sep 9, 2016

@stevenvachon make it available at npm, please.

@stevenvachon
Copy link

stevenvachon commented Sep 9, 2016

@fronteed it already is:

"dependencies": {
  "classlist.js": "stevenvachon/classList.js"
}

@kmohrf
Copy link

kmohrf commented Oct 7, 2016

apart from failing to normalize the api, the current toggle/force polyfill also doesn’t really conform to what everyone else is doing. while I’m not 100% sure that the spec defines this exact edge case (it comes down to the definition of what a passed value is and truthy-/falsyness), every browser seems to consider undefined as not passed, while the current implementation considers undefined false and therefor breaks compatibility.

@tremby
Copy link

tremby commented Oct 7, 2016

In my opinion undefined should definitely be considered "not passed". null should probably be considered false, though I'm not so sure about that.

Probably best to do what the majority of native browser implementations do, if the spec isn't clear enough.

@kmohrf
Copy link

kmohrf commented Oct 7, 2016

null is considered false in other implementations. I suppose the usual thruthy/falsy conversion applies except for undefined. The spec explicitly mentions true and false and in the chromium codebase toggle accepts a bool in the DOMTokenList interface. So I guess they have a standard behaviour concerning function call value transformations for these kind of APIs and undefined is simply dropped while other values are converted to bool.

@beck
Copy link
Collaborator

beck commented May 2, 2017

This should be fixed:
#57

Published via:
https://github.com/yola/classlist-polyfill

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants