Bug 251383 - Reflected ARIA properties should not treat setting undefined the same as null
Summary: Reflected ARIA properties should not treat setting undefined the same as null
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: Accessibility (show other bugs)
Version: Safari Technology Preview
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Nobody
URL:
Keywords: InRadar
Depends on:
Blocks:
 
Reported: 2023-01-30 12:40 PST by Nolan Lawson
Modified: 2023-10-25 09:32 PDT (History)
5 users (show)

See Also:


Attachments
Repro (145 bytes, text/html)
2023-01-30 12:40 PST, Nolan Lawson
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
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.