mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Auto merge of #13081 - hsinewu:nodelist-iterable, r=Ms2ger
make nodeList iterable <!-- Please describe your changes on the following line: --> Not sure what to test in the script. Need some advice. o_O --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: --> - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #13021 (github issue number if applicable). <!-- Either: --> - [X] There are tests for these changes <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/13081) <!-- Reviewable:end -->
This commit is contained in:
commit
1901a21a2c
3 changed files with 44 additions and 1 deletions
|
@ -12,5 +12,5 @@ interface NodeList {
|
||||||
getter Node? item(unsigned long index);
|
getter Node? item(unsigned long index);
|
||||||
[Pure]
|
[Pure]
|
||||||
readonly attribute unsigned long length;
|
readonly attribute unsigned long length;
|
||||||
// iterable<Node>;
|
iterable<Node?>;
|
||||||
};
|
};
|
||||||
|
|
|
@ -37215,6 +37215,12 @@
|
||||||
"deleted_reftests": {},
|
"deleted_reftests": {},
|
||||||
"items": {
|
"items": {
|
||||||
"testharness": {
|
"testharness": {
|
||||||
|
"dom/nodes/NodeList-Iterable.html": [
|
||||||
|
{
|
||||||
|
"path": "dom/nodes/NodeList-Iterable.html",
|
||||||
|
"url": "/dom/nodes/NodeList-Iterable.html"
|
||||||
|
}
|
||||||
|
],
|
||||||
"html/semantics/forms/the-option-element/option-form.html": [
|
"html/semantics/forms/the-option-element/option-form.html": [
|
||||||
{
|
{
|
||||||
"path": "html/semantics/forms/the-option-element/option-form.html",
|
"path": "html/semantics/forms/the-option-element/option-form.html",
|
||||||
|
|
|
@ -0,0 +1,37 @@
|
||||||
|
<!doctype html>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<title>NodeList Iterable Test</title>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<p id="1"></p>
|
||||||
|
<p id="2"></p>
|
||||||
|
<p id="3"></p>
|
||||||
|
<p id="4"></p>
|
||||||
|
<p id="5"></p>
|
||||||
|
<script>
|
||||||
|
var paragraphs;
|
||||||
|
setup(function() {
|
||||||
|
paragraphs = document.querySelectorAll('p');
|
||||||
|
})
|
||||||
|
test(function() {
|
||||||
|
assert_true('length' in paragraphs);
|
||||||
|
}, 'NodeList has length method.');
|
||||||
|
test(function() {
|
||||||
|
assert_true('values' in paragraphs);
|
||||||
|
}, 'NodeList has values method.');
|
||||||
|
test(function() {
|
||||||
|
assert_true('entries' in paragraphs);
|
||||||
|
}, 'NodeList has entries method.');
|
||||||
|
test(function() {
|
||||||
|
assert_true('forEach' in paragraphs);
|
||||||
|
}, 'NodeList has forEach method.');
|
||||||
|
test(function() {
|
||||||
|
assert_true(Symbol.iterator in paragraphs);
|
||||||
|
}, 'NodeList has Symbol.iterator.');
|
||||||
|
test(function() {
|
||||||
|
var ids = "12345", idx=0;
|
||||||
|
for(var node of paragraphs){
|
||||||
|
assert_equals(node.getAttribute('id'), ids[idx++]);
|
||||||
|
}
|
||||||
|
}, 'NodeList is iterable via for-of loop.');
|
||||||
|
</script>
|
Loading…
Add table
Add a link
Reference in a new issue