mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Auto merge of #9763 - Tangresh:i9725, r=nox
Implement value for DOMTokenList Fixes #9725 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.svg" height="40" alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/9763) <!-- Reviewable:end -->
This commit is contained in:
commit
00628704ca
7 changed files with 44 additions and 15 deletions
|
@ -129,6 +129,16 @@ impl DOMTokenListMethods for DOMTokenList {
|
|||
}
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-domtokenlist-value
|
||||
fn Value(&self) -> DOMString {
|
||||
self.element.get_string_attribute(&self.local_name)
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#dom-domtokenlist-value
|
||||
fn SetValue(&self, value: DOMString) {
|
||||
self.element.set_tokenlist_attribute(&self.local_name, value);
|
||||
}
|
||||
|
||||
// https://dom.spec.whatwg.org/#concept-dtl-serialize
|
||||
fn Stringifier(&self) -> DOMString {
|
||||
self.element.get_string_attribute(&self.local_name)
|
||||
|
|
|
@ -19,5 +19,8 @@ interface DOMTokenList {
|
|||
[Throws]
|
||||
boolean toggle(DOMString token, optional boolean force);
|
||||
|
||||
[Pure]
|
||||
attribute DOMString value;
|
||||
|
||||
stringifier;
|
||||
};
|
||||
|
|
|
@ -28,7 +28,7 @@ interface Element : Node {
|
|||
attribute DOMString id;
|
||||
[Pure]
|
||||
attribute DOMString className;
|
||||
[SameObject]
|
||||
[SameObject, PutForwards=value]
|
||||
readonly attribute DOMTokenList classList;
|
||||
|
||||
[SameObject]
|
||||
|
|
|
@ -34514,6 +34514,12 @@
|
|||
"deleted": [],
|
||||
"items": {
|
||||
"testharness": {
|
||||
"dom/lists/DOMTokenList-value.html": [
|
||||
{
|
||||
"path": "dom/lists/DOMTokenList-value.html",
|
||||
"url": "/dom/lists/DOMTokenList-value.html"
|
||||
}
|
||||
],
|
||||
"html/webappapis/scripting/events/event-handler-processing-algorithm.html": [
|
||||
{
|
||||
"path": "html/webappapis/scripting/events/event-handler-processing-algorithm.html",
|
||||
|
|
|
@ -162,18 +162,12 @@
|
|||
[DOMSettableTokenList interface object name]
|
||||
expected: FAIL
|
||||
|
||||
[Element interface: attribute classList]
|
||||
expected: FAIL
|
||||
|
||||
[DOMTokenList interface: operation replace(DOMString,DOMString)]
|
||||
expected: FAIL
|
||||
|
||||
[DOMTokenList interface: operation supports(DOMString)]
|
||||
expected: FAIL
|
||||
|
||||
[DOMTokenList interface: attribute value]
|
||||
expected: FAIL
|
||||
|
||||
[DOMTokenList interface: document.body.classList must inherit property "replace" with the proper type (6)]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -186,6 +180,3 @@
|
|||
[DOMTokenList interface: calling supports(DOMString) on document.body.classList with too few arguments must throw TypeError]
|
||||
expected: FAIL
|
||||
|
||||
[DOMTokenList interface: document.body.classList must inherit property "value" with the proper type (8)]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,5 +0,0 @@
|
|||
[Element-classlist.html]
|
||||
type: testharness
|
||||
[classList must have [PutForwards=value\]]
|
||||
expected: FAIL
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<!DOCTYPE html>
|
||||
<meta charset="utf-8">
|
||||
<title>DOMTokenList value</title>
|
||||
<link rel=help href="https://dom.spec.whatwg.org/#dom-domtokenlist-value">
|
||||
<link rel=author title=Tangresh href="mailto:dmenzi@tangresh.ch">
|
||||
<script src="/resources/testharness.js"></script>
|
||||
<script src="/resources/testharnessreport.js"></script>
|
||||
<span class=" a a b "></span>
|
||||
<script>
|
||||
test(function() {
|
||||
assert_equals(String(document.createElement("span").classList.value), "",
|
||||
"classList.value should return the empty list for an undefined class attribute");
|
||||
var span = document.querySelector("span");
|
||||
assert_equals(span.classList.value, " a a b ",
|
||||
"value should return the literal value");
|
||||
span.classList.value = " foo bar foo ";
|
||||
assert_equals(span.classList.value, " foo bar foo ",
|
||||
"assigning value should set the literal value");
|
||||
assert_equals(span.classList.length, 2,
|
||||
"length should be the number of tokens");
|
||||
assert_class_string(span.classList, "DOMTokenList");
|
||||
assert_class_string(span.classList.value, "String");
|
||||
});
|
||||
</script>
|
Loading…
Add table
Add a link
Reference in a new issue