Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upMake NodeList iterable #13021
Make NodeList iterable #13021
Comments
|
I would like to work on this. |
|
Sure thing! Here are a couple of key things to look out for: |
|
No, those are only used for pair iterables; the value iterables like this one are less complex. |
|
No idea what webidl is doing there Orz What does the question mark mean? nullable? The feeling of reading specs... |
|
The ? does mean nullable, yes. I copied the line from Firefox's WebIDL, but we could see if the non-nullable one works. |
|
Got No idea what's going on, just do some recording. |
|
How can I prove nodes to be iterable? for-loop? Any specific dom function to test out? |
|
Oh, querySelectorAll |
|
You may take #12998 as a reference |
|
And continue my last advice, the tests/wpt/metadata/fetch/api/headers/headers-structure.html might be a good example of testing iterable |
|
@izgzhen I found no html files in that commit, it's some rust and .html.ini files, or do you mean those impl are the feature needed to be tested, and can served as hints to do corresponding test in javascript? Also, I can't find |
|
Oh, I was looking for it under metadata folder, it was my wrong :/ |
|
@jdm As far as I find, we don't codegen anything for value iterator? But looks like |
|
They are generated, but they're self-hosted JS code so no changes are necessary in the rust implementation. |
|
@jdm I don't understand what you mean by 'self-hosted', would you clarify it for me? I assume, by iterable it means it has forEach, vlalues, entries, keys methods, but there were not in my experiment, which means either
Is this the right way to do it? Also, would you take a look at #13081? |
|
Here, 'self-hosted' means that a custom implementation of |
|
@hsinewu I added the <span>hi</span>
<script>
var o = document.querySelectorAll('span');
console.log('length' in o);
console.log('forEach' in o);
console.log('values' in o);
console.log('keys' in o);
console.log(Symbol.iterator in o);
</script>Every line printed |
|
@jdm Fail to reproduce the problem, I might have been messed up with the build. |
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 -->
Blocked on #12819. We're missing
iterable<Node?>;fromNodeList.webidl. I believe that adding it should be all that's necessary to make iteration over NodeList values like the result ofdocument.querySelectorAll.Code:
components/script/dom/webidls/NodeList.webidl,components/script/dom/nodelist.rsTest: create a test in
tests/wpt/web-platform-tests/dom/nodesthat tests the properties of the iterating over a NodeList