mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
Auto merge of #25202 - Eijebong:domtokenlist_replace, r=jdm
Return a boolean from DOMTokenList::replace to match the spec Fixes #25129
This commit is contained in:
commit
ebe432bf58
3 changed files with 5 additions and 333 deletions
|
@ -151,7 +151,7 @@ impl DOMTokenListMethods for DOMTokenList {
|
||||||
}
|
}
|
||||||
|
|
||||||
// https://dom.spec.whatwg.org/#dom-domtokenlist-replace
|
// https://dom.spec.whatwg.org/#dom-domtokenlist-replace
|
||||||
fn Replace(&self, token: DOMString, new_token: DOMString) -> ErrorResult {
|
fn Replace(&self, token: DOMString, new_token: DOMString) -> Fallible<bool> {
|
||||||
if token.is_empty() || new_token.is_empty() {
|
if token.is_empty() || new_token.is_empty() {
|
||||||
// Step 1.
|
// Step 1.
|
||||||
return Err(Error::Syntax);
|
return Err(Error::Syntax);
|
||||||
|
@ -164,6 +164,7 @@ impl DOMTokenListMethods for DOMTokenList {
|
||||||
let token = Atom::from(token);
|
let token = Atom::from(token);
|
||||||
let new_token = Atom::from(new_token);
|
let new_token = Atom::from(new_token);
|
||||||
let mut atoms = self.element.get_tokenlist_attribute(&self.local_name);
|
let mut atoms = self.element.get_tokenlist_attribute(&self.local_name);
|
||||||
|
let mut result = false;
|
||||||
if let Some(pos) = atoms.iter().position(|atom| *atom == token) {
|
if let Some(pos) = atoms.iter().position(|atom| *atom == token) {
|
||||||
if !atoms.contains(&new_token) {
|
if !atoms.contains(&new_token) {
|
||||||
atoms[pos] = new_token;
|
atoms[pos] = new_token;
|
||||||
|
@ -173,8 +174,9 @@ impl DOMTokenListMethods for DOMTokenList {
|
||||||
// Step 5.
|
// Step 5.
|
||||||
self.element
|
self.element
|
||||||
.set_atomic_tokenlist_attribute(&self.local_name, atoms);
|
.set_atomic_tokenlist_attribute(&self.local_name, atoms);
|
||||||
|
result = true;
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
// check-tidy: no specs after this line
|
// check-tidy: no specs after this line
|
||||||
|
|
|
@ -19,7 +19,7 @@ interface DOMTokenList {
|
||||||
[CEReactions, Throws]
|
[CEReactions, Throws]
|
||||||
boolean toggle(DOMString token, optional boolean force);
|
boolean toggle(DOMString token, optional boolean force);
|
||||||
[CEReactions, Throws]
|
[CEReactions, Throws]
|
||||||
void replace(DOMString token, DOMString newToken);
|
boolean replace(DOMString token, DOMString newToken);
|
||||||
|
|
||||||
[CEReactions, Pure]
|
[CEReactions, Pure]
|
||||||
stringifier attribute DOMString value;
|
stringifier attribute DOMString value;
|
||||||
|
|
|
@ -75,333 +75,3 @@
|
||||||
[classList.replace("c", "a") with attribute value "c b a" (foo node)]
|
[classList.replace("c", "a") with attribute value "c b a" (foo node)]
|
||||||
expected: FAIL
|
expected: FAIL
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value "a" (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("A", "b") with attribute value "a" (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "A") with attribute value "a b" (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("c", "a") with attribute value "a b" (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("d", "e") with attribute value "a b c" (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("c", "d") with attribute value "a a a b" (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value null (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value "" (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value " " (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value " a \\f" (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "d") with attribute value "a b c" (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("c", "a") with attribute value "a b c" (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "c") with attribute value "a b a" (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "c") with attribute value "a b a" (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "c") with attribute value " a a b" (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "c") with attribute value " a a b" (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "c") with attribute value "\\t\\n\\f\\r a\\t\\n\\f\\r b\\t\\n\\f\\r " (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "c") with attribute value "\\t\\n\\f\\r a\\t\\n\\f\\r b\\t\\n\\f\\r " (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace(null, "b") with attribute value "a null" (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", null) with attribute value "a b" (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace(undefined, "b") with attribute value "a undefined" (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", undefined) with attribute value "a b" (HTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value "a" (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("A", "b") with attribute value "a" (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "A") with attribute value "a b" (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("c", "a") with attribute value "a b" (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("d", "e") with attribute value "a b c" (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("c", "d") with attribute value "a a a b" (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value null (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value "" (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value " " (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value " a \\f" (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "d") with attribute value "a b c" (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("c", "a") with attribute value "a b c" (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "c") with attribute value "a b a" (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "c") with attribute value "a b a" (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "c") with attribute value " a a b" (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "c") with attribute value " a a b" (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "c") with attribute value "\\t\\n\\f\\r a\\t\\n\\f\\r b\\t\\n\\f\\r " (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "c") with attribute value "\\t\\n\\f\\r a\\t\\n\\f\\r b\\t\\n\\f\\r " (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace(null, "b") with attribute value "a null" (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", null) with attribute value "a b" (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace(undefined, "b") with attribute value "a undefined" (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", undefined) with attribute value "a b" (XHTML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value "a" (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("A", "b") with attribute value "a" (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "A") with attribute value "a b" (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("c", "a") with attribute value "a b" (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("d", "e") with attribute value "a b c" (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("c", "d") with attribute value "a a a b" (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value null (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value "" (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value " " (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value " a \\f" (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "d") with attribute value "a b c" (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("c", "a") with attribute value "a b c" (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "c") with attribute value "a b a" (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "c") with attribute value "a b a" (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "c") with attribute value " a a b" (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "c") with attribute value " a a b" (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "c") with attribute value "\\t\\n\\f\\r a\\t\\n\\f\\r b\\t\\n\\f\\r " (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "c") with attribute value "\\t\\n\\f\\r a\\t\\n\\f\\r b\\t\\n\\f\\r " (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace(null, "b") with attribute value "a null" (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", null) with attribute value "a b" (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace(undefined, "b") with attribute value "a undefined" (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", undefined) with attribute value "a b" (MathML node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value "a" (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("A", "b") with attribute value "a" (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "A") with attribute value "a b" (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("c", "a") with attribute value "a b" (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("d", "e") with attribute value "a b c" (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("c", "d") with attribute value "a a a b" (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value null (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value "" (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value " " (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value " a \\f" (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "d") with attribute value "a b c" (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("c", "a") with attribute value "a b c" (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "c") with attribute value "a b a" (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "c") with attribute value "a b a" (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "c") with attribute value " a a b" (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "c") with attribute value " a a b" (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "c") with attribute value "\\t\\n\\f\\r a\\t\\n\\f\\r b\\t\\n\\f\\r " (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "c") with attribute value "\\t\\n\\f\\r a\\t\\n\\f\\r b\\t\\n\\f\\r " (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace(null, "b") with attribute value "a null" (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", null) with attribute value "a b" (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace(undefined, "b") with attribute value "a undefined" (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", undefined) with attribute value "a b" (XML node with null namespace)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value "a" (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("A", "b") with attribute value "a" (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "A") with attribute value "a b" (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("c", "a") with attribute value "a b" (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("d", "e") with attribute value "a b c" (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("c", "d") with attribute value "a a a b" (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value null (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value "" (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value " " (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "b") with attribute value " a \\f" (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "d") with attribute value "a b c" (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("c", "a") with attribute value "a b c" (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "c") with attribute value "a b a" (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "c") with attribute value "a b a" (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "c") with attribute value " a a b" (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "c") with attribute value " a a b" (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", "c") with attribute value "\\t\\n\\f\\r a\\t\\n\\f\\r b\\t\\n\\f\\r " (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("b", "c") with attribute value "\\t\\n\\f\\r a\\t\\n\\f\\r b\\t\\n\\f\\r " (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace(null, "b") with attribute value "a null" (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", null) with attribute value "a b" (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace(undefined, "b") with attribute value "a undefined" (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
[classList.replace("a", undefined) with attribute value "a b" (foo node)]
|
|
||||||
expected: FAIL
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue