Clarify hidden elements do not return name - #533
Conversation
closes #370 Adds comments to label, legend and caption elements to indicate that if they are hidden, then they will not return a name for their associated elements. Note that right now this means that ``` <label for=d hidden>foo</label> <input id=d title=bar> ``` has _no name_. The label is still referenced, but because it is hidden it returns an empty name in Safari and Chromium browsers. Firefox correctly returns "bar" as the name of the input.
fstrr
left a comment
There was a problem hiding this comment.
I did wonder about keeping the existing caption comment, but removing it is in line with the lack of similar comments in the document.
adampage
left a comment
There was a problem hiding this comment.
Heya @scottaohara, I’ve just pushed up a some new WPT tests in web-platform-tests/wpt#44965 to support this PR. / cc @cookiecrook.
I hope I avoided the overlap and ballooning you cautioned against. 🤞🏻 Please let me know if you think they’re sensible/sufficient?
|
to be clear, the stuff i was really hoping for discussion on with the review of this PR was things like should hidden labels/legends/captions continue to even be associated with their respective elements, if they are hidden? And thus, returning no name. The example i brought up on the call was where the above example applies to tables and fieldsets with captions and legends, respectively. there is inconsistency in how the above is treated. where some browsers return an empty name for the input. And I believe I said it was Firefox returns "blargh" as the name of the input. based on what this spec already has written for how these elements are named (input naming as an example)
My understanding is that Firefox is doing the right thing, and chromium/webkit are incorrectly stopping with the returned empty string from the hidden label/caption/legend. But since 2 browsers aren't following what the spec says, I am doubting myself if there's somehow a lack of clarity here. |
|
I agree, the “If empty, then...” statements are unambiguous and Firefox is doing the right thing. In contrast, 4.1.2 has a more wobbly “Otherwise, if the control still has no accessible name use title attribute”. For this one, Chrome and Webkit could argue that the control does have an accessible name, it just happens to be empty. Looking down the list of elements, I also see So it does seem like there’s an opportunity to normalize all of the elements to that “if empty” phrasing so that |
|
The
...reads crystal clear to me. If you think normalizing all the 4.1 elements to this pattern would be sensible, I’d be happy to take a stab at that as a separate PR, and also add some more WPT tests for the |
|
Agree that Firefox is doing the right thing in using the Adam's suggestion to Normalize the 4.1 content to match the |
|
i say let's just get that input consistency into this PR. we should probably do another PR / tests for the following, though the table/fieldset already seem like they're clear at first glance. but from what i've seen one could have where the initial legend is hidden and an 'invalid' second legend is rendered instead. visually, this looks just fine, but the accName calc stops at the hidden legend, and doesn't get to the actually rendered legend to get a name from that. Is that actually what people expect should happen here? |
|
Yeah, I see. Since the browser goes ahead and permissively renders that invalid second
In the above step from 4.1.5, “the first such element” is plainly specific but also suggests a tolerance for multiple An allowance for invalid multi-
I guess we’re basically just doing our best to imitate whatever error correction algorithm that browsers are doing for rendering invalid HTML. Which I suppose is — please forgive my naivete — not standardized, or at least not specified anywhere that we could reference or copy? |
|
closing as now being handled in aria PR 2214 |
closes #370
Adds comments to label, legend and caption elements to indicate that if they are hidden, then they will not return a name for their associated elements.
Note that right now this means that
has no name. The label is still referenced, but because it is hidden it returns an empty name in Safari and Chromium browsers. Firefox correctly returns "bar" as the name of the input.
I think this can probably be made more clear in the naming steps, and I can make some wpts for this... i'm just not sure exactly where to put them now without potentially overlapping or ballooning out some of the existing tests. probably worth talking about that when we triage this.
The PR also includes some consistency cleanup for legend/caption.
Implementation
Preview | Diff