-
Notifications
You must be signed in to change notification settings - Fork 295
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
Future for unique tokens in DOMTokenList #201
Comments
FWIW, Safari Technology Preview has fixed all those bugs and is now following the spec. EDIT: See #105 (comment) though, they are serializing on regular stringification as well. |
This is what I get in Safari Tech Preview for this test case: var el = document.createElement("div");
el.className = " a a b ";
console.log(el.className.length); // 7
console.log(el.classList.length); // 2
console.log(Array.prototype.slice.call(el.classList).join(" ")); // "a b"
el.classList.add("a"); // should remove duplicate and white space in associated attr value
console.log(el.className.length); // 3
console.log(el.classList.length); // 2
console.log(Array.prototype.slice.call(el.classList).join(" ")); // "a b"
el.classList.remove("a");
console.log(el.className.length); // 1
console.log(el.classList.length); // 1
console.log(Array.prototype.slice.call(el.classList).join(" ")); // "b" So it seems to be serializing very aggressively. |
Still something is wrong, |
It's |
Oh right, sorry, so it's correct:). Have you access to Edge, what result we get on this engine? |
Yes, WebKit trunk always drops duplicates and cleans up whitespace currently. It looks like I need to change so that we only do this on add/remove/toggle/update/replace? |
Edge 13.10586: var el = document.createElement("div");
el.className = " a a b ";
console.log(el.className.length); // 7
console.log(el.classList.length); // 3
console.log(Array.prototype.slice.call(el.classList).join(" ")); // "a a b"
el.classList.add("a"); // should remove duplicate and white space in associated attr value
console.log(el.className.length); // 7
console.log(el.classList.length); // 3
console.log(Array.prototype.slice.call(el.classList).join(" ")); // "a a b"
el.classList.remove("a");
console.log(el.className.length); // 1
console.log(el.classList.length); // 1
console.log(Array.prototype.slice.call(el.classList).join(" ")); // "b" |
@mgol Can you report what Safari Tech Preview product for this (commetns represent value from Firefox and Chrome): <script>
var el = document.createElement("div");
el.classList = " a a b ";
console.log(el.className.length); // 7
console.log(el.classList.length); // 3
console.log(el.attributes[0].value); // " a a b "
console.log(Array.prototype.slice.call(el.classList).join(" ")); // "a a b"
</script> |
var el = document.createElement("div");
el.classList = " a a b ";
console.log(el.className.length); // 3
console.log(el.classList.length); // 2
console.log(el.attributes[0].value); // "a b"
console.log(Array.prototype.slice.call(el.classList).join(" ")); // "a b" |
So, per DOM, it's wrong: setting |
@ArkadiuszMichalski Please read my post on GitHub, I pasted some things wrong and edited it immediately, you see the old thing when you look at the mail. |
I use GitHub but I had to reload the page, ok, so I removed this "last space" question. |
@ArkadiuszMichalski : Why is the behavior wrong? el.classList = " a a b "; shouldn't it? in which case, el.attributes[0].value should probably return "a b". If there is a bug, I don't mind fixing it but this looks like expected behavior to me. Well, that is before the following change: Which we are trying to get reverted via: At least, this is my interpretation of: |
@cdumez Changing stringifier for Recently a lot of changes were made around sets and hard to follow them, especially when browsers still operate in their own way. The current definition doesn't look bad and really, if others don't follow the new changes, it makes no sense to modify anything in DOM once again. |
Okay to mark this as a duplicate of #105? |
@annevk If #105 also fix (clarify) this case #201 (comment) then you can close. Due #201 (comment) Safari Technology Preview make progress here, but still not correct per spec.. I still look implementation of this at least in one engine in Windows (even in dev version). Observing the progress of work in this area I wondering why you want change DOMTokenList stringifier, now DOM describe behaviour of Edge/IE/Blink/Gecko vs alone Webkit, so what change requires less effort? |
@ArkadiuszMichalski I'm folding this into #105, if I'm overlooking something let me know, but my plan is to file bugs against all browsers apart from WebKit and see how that shakes out. Also, going forward I'll make sure (and you should remind me) to include tests for normative changes so we don't end up in this situation again. It's clearly not great and apologies for that. |
Per DOM tokens in DOMTokenList should be unique, which is provided by ordered set parser. But after long time already beyond this is not implemented by any engine, or mabye I wrong so please correct me (Edge, Webkit or Servo do this?).
Some bugs from Mozilla:
https://bugzilla.mozilla.org/show_bug.cgi?id=869788
https://bugzilla.mozilla.org/show_bug.cgi?id=910121
Repeated tokens cause that other definition around DOMTokenList are not valid, for example invoking
add()
should run the "update steps" (what means set associated attr to new value taken from ordered set serializer for tokens, so this attr's value should have unique tokens too). But browsers don't do this and we get repeated tokens. In the other site forremove()
we get better behaviour (but not in all engine).Unique tokens in DOMTokenList still are considered as something attainable in the near future?
The text was updated successfully, but these errors were encountered: