Description
What is the issue with the HTML Standard?
https://html.spec.whatwg.org/#dom-innertext says
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':
select elements have an associated non-replaced inline CSS box whose child boxes include only those of optgroup and option element child nodes;
optgroup elements have an associated non-replaced block-level CSS box whose child boxes include only those of option element child nodes; and
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:
- tweak it to include descendant
optgroup
/option
s, not just children - remove the special casing
- 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:
- The spec does not deal with replaced elements like <select> which have textContent but no innerText rocallahan/innerText-spec#1
- innerText should be supported for the <option> elements in a <select> rocallahan/innerText-spec#5
cc @josepharhar