question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Fix option.value/text/label

See original GitHub issue

I’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:closed
  • Created 7 years ago
  • Comments:7 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
miggs125commented, May 16, 2019

I would like to contribute to this. What parts (if any) of the issue still need to be resolved?

0reactions
Zirrocommented, May 16, 2019

@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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

HTML select shows value instead of text - Stack Overflow
You can do it by using the label tag: <option value="the_value" label="the text displayed">the hidden text</option>.
Read more >
Element “option” without attribute “label” must not be empty.
Guide describing the HTML issue detected by the W3C Validator: Element “option” without attribute “label” must not be empty.
Read more >
How to show label text of select option rather than its value
Hi, If I create a select field for a product, on the cart page, it will show the selected option's value rather than...
Read more >
The HTML Option element - MDN Web Docs - Mozilla
If the label attribute isn't defined, its value is that of the element text content. selected. If present, this Boolean attribute indicates that ......
Read more >
HTML option label Attribute - W3Schools
Definition and Usage. The label attribute specifies a shorter version of an option. The shorter version will be displayed in the drop-down list....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found