Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update "undefined" definition in section 6.2.4 Value (within 6.2 Characteristics of States and Properties) #2172

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10013,7 +10013,7 @@ <h3>Value</h3>
<dt id="valuetype_tristate">tristate</dt>
<dd>Value representing <code>true</code>, <code>false</code>, <code>mixed</code>, or <code>undefined</code> values. The default value for this value type is <code>undefined</code> unless otherwise specified.</dd>
<dt id="valuetype_true-false-undefined">true/false/undefined</dt>
<dd>Value representing <code>true</code>, <code>false</code>, or <code>undefined</code> (not applicable). The default value for this value type is <code>undefined</code> unless otherwise specified. For example, an element with <sref>aria-expanded</sref> set to <code>false</code> is not currently expanded; an element with <sref>aria-expanded</sref> set to <code>undefined</code> is not expandable.</dd>
<dd>Value representing <code>true</code>, <code>false</code>, or <code>undefined</code> (not applicable). Unless otherwise specified, the default value for this value type is <code>undefined</code>. Note that the value <code>undefined</code> conveys a state- or property-dependent behavior including but not limited to lack of support (e.g., <sref>aria-checked</sref>, <sref>aria-pressed</sref>), equivalence with the value <code>false</code> (e.g., <sref>aria-multiselectable</sref>), behavior determined by the user agent (e.g., <sref>aria-hidden</sref>) or non-applicability (e.g., <sref>aria-selected</sref>).
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow this really shows how inconsistent we have been with the use of undefined 😅

I wonder if we should include the examples, or leave it at Note that the value undefined conveys a state- or property-dependent behavior, consult the values table of the relevant state or property to understand the meaning of an undefined state or property.

Copy link
Contributor

@smhigley smhigley May 2, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's actually even more complex than this :/. For example, el.ariaChecked = undefined is going to default to the same as false for most roles, only excluding option and treeitem. I think it may be better to not reference specific attributes here. Even for something like aria-pressed, if HTML ever ends up creating a toggle button element, then aria-pressed being undefined would not mean it is not supported. It might be simpler to stick with only one relatively safe example (e.g. the aria-expanded one in the original text), then clarify that for specific behavior, authors should check the tables for that attribute?

I do also think I agree with Valerie that it'd be helpful to clarify that undefined here refers to the value, which is set by either leaving the attribute off entirely or explicitly setting e.g. element.ariaExpanded = undefined, and is not equivalent to the string "undefined" in e.g. aria-expanded="undefined". What do you think?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think "undefined" needs to be yanked out of the <code> unless it explicitly means the string value "undefined".

As a user of the spec, this is what I might expect (fake example) so I could make sense of it:

Values include yeah, nah, undefined, or undefined (by setting no value).

Copy link
Contributor

@smhigley smhigley May 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@aardrian would it help if this section had a link to the IDL reflection section just after it, in addition to text clarifying that undefined is not the string + the (by setting no value) parenthetical?

It does get weirder, in that while you can explicitly set e.g. el.ariaThing = undefined, getting it returns null 🤷🏻‍♀️

Copy link
Contributor Author

@rahimabdi rahimabdi May 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @aardrian @smhigley. As @spectranaut noted, it's currently ambiguous if the value undefined is the string "undefined" or undefined as in not present (or the value undefined). For example, see Note 2 under aria-hidden:

As of ARIA 1.3, aria-hidden="false" is now synonymous with aria-hidden="undefined".

I'm also observing that attr = "undefined" passes HTML validation (W3C Validator). Is this intended or a bug?

Copy link
Contributor

@smhigley smhigley May 10, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@rahimabdi yeah, I believe that's a pretty straightforward mistake in the spec. I made a test page to output the browser-mapped values when ARIA attributes are set to the string "undefined", not set at all, or set programmatically to undefined: https://jsfiddle.net/pobwvgs9/

I checked it in Chrome, Edge, Safari, and Firefox on macOS and Windows (Safari only on mac), and all of them had different results for the string "undefined". The results for not-defined and programmatic = undefined values are what I'd expect & what matches the spec, while the string "undefined" are not.

My proposal would be that we go through the spec and remove any instances accidentally using string ="undefined", and add the clarification of the string not being the same as the value.

As an aside, I do get an error for ="undefined" in the W3C Validator, maybe they have some bugs in the attributes you tested?
Screenshot of the HTML validator having been run on a button with aria-hidden=undefined and aria-pressed=foo. The validator shows one error for each attribute.

<dt id="valuetype_idref">ID reference</dt>
<dd>Reference to the ID of another <a>element</a> in the same document</dd>
<dt id="valuetype_idref_list">ID reference list</dt>
Expand Down
Loading