Skip to content

innerText getter impact of customizable select #11017

Open
@zcorpan

Description

@zcorpan

What is the issue with the HTML Standard?

https://html.spec.whatwg.org/#dom-innertext says

  1. If node is not being rendered, then return items. For the purpose of this step, the following elements must act as described if the computed value of the 'display' property is not 'none':

    1. select elements have an associated non-replaced inline CSS box whose child boxes include only those of optgroup and option element child nodes;

    2. optgroup elements have an associated non-replaced block-level CSS box whose child boxes include only those of option element child nodes; and

    3. option element have an associated non-replaced block-level CSS box whose child boxes are as normal for non-replaced block-level CSS boxes.

Given <select><div><option>foo</option></div></select>, select.innerText would be the empty string (because there is no option child node), which is different from old select parsing (where the div is dropped).

Relevant tests: https://wpt.fyi/results/html/dom/elements/the-innertext-and-outertext-properties/getter.html?label=master&label=experimental&aligned&q=innertext

Also currently innerText per spec would drop text outside of optgroup/option in select. (e.g. <select>foo</select> per the current spec gives the empty string.)

I suppose the options are:

  1. tweak it to include descendant optgroup/options, not just children
  2. remove the special casing
  3. keep the innerText spec as-is

I think (1) seems safest in terms of web compat, but I don't know if there are strong web compat constraints here.

Also see:

cc @josepharhar

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions