Skip to content
This repository has been archived by the owner on Nov 11, 2019. It is now read-only.

<span class="a b c">.classList.replace("c", "a") -> "a b" or "b a"? #117

Closed
ayg opened this issue Apr 5, 2017 · 3 comments
Closed

<span class="a b c">.classList.replace("c", "a") -> "a b" or "b a"? #117

ayg opened this issue Apr 5, 2017 · 3 comments
Assignees
Milestone

Comments

@ayg
Copy link

ayg commented Apr 5, 2017

The spec just says "Replace token in tokens with newToken", but this doesn't actually work in an ordered set, because if you actually replaced it as instructed, the set would have a duplicate entry. Test-case:

data:text/html,<!doctype html>
<script>
var span = document.createElement("span");
span.setAttribute("class", "a b c");
span.classList.replace("c", "a");
document.documentElement.textContent = span.getAttribute("class");
</script>

Firefox Aurora says "a b". Chrome doesn't seem to support .replace(). I don't have Edge or WebKit handy yet to test.

@kkdomono
Copy link

I tested with Safari 10.1, it say "a b" too, same as FireFox.

@yongsheng
Copy link
Collaborator

yongsheng commented Apr 16, 2017

thanks, @linzhiping . I think we'll add it in DOM4.1. @chaals

@linzhiping will take over this issue.

@yongsheng yongsheng added this to the m4 milestone Apr 16, 2017
yongsheng pushed a commit to yongsheng/dom that referenced this issue May 17, 2017
Changes in Terminology.
Add a definition to "ordered set" and clarify the replace
operation to make sure the behavior is clear.
yongsheng pushed a commit to yongsheng/dom that referenced this issue May 17, 2017
1. Define token set using ordered set for DOMTokenList.

2. Refine DOMTokenList's length and indexing.

3. Make DOMTokenList's contains() not throw because it doesn't modify token set.

4. Combine DOMSettableTokenList into DOMTokenList, because DOMTokenList.value

   could be a stringifier attribute, therefore it is OK to make 'value' a

   stringifier.

5. Use less loops for DOMTokenList's add() and remove().

6. Always update a DOMTokenList when invoking toggle(). This shall normalize

   duplicates and whitespaces even if they're no-ops like add()/remove().

   This fixes w3c#118 too.

7. Introduce DOMTokenList's replace(). This shall fix w3c#117 together.

8. Introduce DOMTokenList's supports().
yongsheng pushed a commit that referenced this issue May 17, 2017
Changes in Terminology.
Add a definition to "ordered set" and clarify the replace
operation to make sure the behavior is clear.
yongsheng pushed a commit that referenced this issue May 17, 2017
1. Define token set using ordered set for DOMTokenList.

2. Refine DOMTokenList's length and indexing.

3. Make DOMTokenList's contains() not throw because it doesn't modify token set.

4. Combine DOMSettableTokenList into DOMTokenList, because DOMTokenList.value

   could be a stringifier attribute, therefore it is OK to make 'value' a

   stringifier.

5. Use less loops for DOMTokenList's add() and remove().

6. Always update a DOMTokenList when invoking toggle(). This shall normalize

   duplicates and whitespaces even if they're no-ops like add()/remove().

   This fixes #118 too.

7. Introduce DOMTokenList's replace(). This shall fix #117 together.

8. Introduce DOMTokenList's supports().
@zqzhang
Copy link
Member

zqzhang commented May 19, 2017

This shall be fixed.

@zqzhang zqzhang closed this as completed May 19, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants