Fix option.value/text/label
See original GitHub issueI’m filing this as a good bug for someone who wants to contribute to jsdom, as it’s a pretty straightforward instance of updating jsdom to match the spec.
Currently, our implementations of the value
, text
, and label
properties of <option>
elements are incorrect. They can be seen in HTMLOptionElement-impl.js, with comments on the wrong parts.
We have tests for these already in place, but commented out: after https://github.com/tmpvar/jsdom/pull/1722 lands, there will be four lines in web-platform-tests/index.js for “html/semantics/forms/the-option-element/” that are commented out. The goal is to uncomment those lines, and then get npm run test-wpt
to pass.
You may find it easier to run the tests if you comment out all the other tests in that file besides those four during development, as the rest of the tests in that file take a while to run.
To make the tests pass, you need to implement the spec:
Note how fixing text
makes the others much easier to fix, as they delegate to it.
The hardest part of implementing text
will be doing appropriate DOM node crawling. You’re going to want to use domSymbolTree.treeIterator. Ctrl+F the codebase to find similar usages. Don’t forget CDATA sections (which are a type of Text node). The code in Node-impl.js’s textContent implementation would be a good starting point, although the script element business will be tricky. You may find the closest
utility, in helpers/traversal, helpful.
Hope this sounds fun for someone!
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (2 by maintainers)
Top GitHub Comments
I would like to contribute to this. What parts (if any) of the issue still need to be resolved?
@miggs125 The value and label properties were fixed recently and https://github.com/jsdom/jsdom/pull/2550 contains WIP code for the text property that I’ll likely return to soon, so there’s probably not that much left to do in this particular issue. Your interest in helping out is still very appreciated though, so feel free to take a look at other issues as well.