Bug 251383

Summary: Reflected ARIA properties should not treat setting undefined the same as null
Product: WebKit Reporter: Nolan Lawson <nlawson>
Component: AccessibilityAssignee: Nobody <webkit-unassigned>
Status: RESOLVED INVALID    
Severity: Normal CC: andresg_22, rego, rniwa, tyler_w, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: Safari Technology Preview   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Repro none

Description Nolan Lawson 2023-01-30 12:40:40 PST
Created attachment 464760 [details]
Repro

Safari Technology Preview version: Release 146 (Safari 15.4, WebKit 16614.1.14.10.6)

Steps to reproduce:

1. Go to https://codepen.io/nolanlawson-the-selector/pen/OJwojEW

What is the expected result?

It should log "undefined" (the string).

What happens instead?

It logs null.

Here is the minimal repro (same as in the CodePen):

    const div = document.createElement('div')
    div.ariaLabel = undefined
    console.log(div.ariaLabel)

Per the ARIA spec [1], setting `null` on a reflected `aria*` property removes the associated `aria-` attribute (if it exists). However, it doesn't say anything about setting `undefined`.

So in this case, setting `undefined` should presumably be treated the same as any other non-string value – i.e. it should be stringified:

    div.ariaLabel = undefined
    div.ariaLabel // 'undefined'
    div.getAttribute('aria-label') // 'undefined'

Note that Chrome and Safari behave identically, and Firefox has not implemented ARIA reflection yet. More details are in the relevant ARIA bug [2].

I also filed a bug on Chromium [3].

[1]: https://w3c.github.io/aria/#enumerated-attribute-values-html
[2]: https://github.com/w3c/aria/issues/1858
[3]: https://bugs.chromium.org/p/chromium/issues/detail?id=1411465
Comment 1 Radar WebKit Bug Importer 2023-01-31 13:04:18 PST
<rdar://problem/104881298>
Comment 2 Nolan Lawson 2023-10-25 09:32:10 PDT
This issue can be closed per tentative resolution in https://github.com/w3c/aria/pull/2057. Once the spec is updated, WebKit's behavior will be correct per the spec.