Bug 95631 (grumble)
| Summary: | element.classList.remove("x") on an element with only class "x" leaves <p class> instead of <p class=""> | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Alex <dunn.alex> |
| Component: | DOM | Assignee: | Nobody <webkit-unassigned> |
| Status: | RESOLVED INVALID | ||
| Severity: | Trivial | CC: | ahmad.saleem792, ap, bfulgham, rniwa |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | Mac (Intel) | ||
| OS: | OS X 10.8 | ||
Alex
By inspecting the <h1> element in this jsFiddle, you can see that using classList.remove to remove the only class from an element results in, e.g., <h1 class>, when it seems that the right result is <h1 class="">:
http://jsfiddle.net/gyre/6rVJU/
The current HTML5 draft says that the class attribute, "if specified, must have a value" (http://dev.w3.org/html5/spec-author-view/global-attributes.html#classes). But neither the regular or "nu" W3 validators flag this as invalid, so I doubt it's important. Gecko does have the "correct" behavior, though.
Tested on Safari 6.0 (8536.25), Webkit 537+, and Chrome 21.0.1180.89
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Ahmad Saleem
I am unable to reproduce this bug using attached test case from Comment 0 in Safari 15.6 on macOS 12.5. Clicking on "Whatever happened to class?" do nothing and does not generate any Console logs. It is similar in other browsers (Chrome Canary 106 and Firefox 105) and clicking on button do nothing.
Considering it was working in Gecko (Firefox) before and they have changed their behavior. I would consider this as "RESOLVED INVALID" and mark accordingly.
In case, if I am wrong or testing incorrectly, please comment or mark this bug accordingly. Thanks!