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

Editorial updates to attribute reflection and enumerated attributes #7956

Merged
merged 6 commits into from
Jun 8, 2022

Conversation

domenic
Copy link
Member

@domenic domenic commented May 24, 2022

Myself and @zcorpan got ourselves confused around openui/open-ui#533 (comment) . So I rewrote the confusing sections.


/common-dom-interfaces.html ( diff )
/common-microsyntaxes.html ( diff )
/urls-and-fetching.html ( diff )

This is easier to read, partially because it spreads out the steps and branches, and partially because of the asserts making some conditions explicit.
Notably this gives an explicit algorithm for determining the state, instead of a couple paragraphs of prose. It also broadens the definition of "canonical keyword" to automatically be determined in simpler cases, instead of only used in tricky cases.
@domenic domenic added the clarification Standard could be clearer label May 24, 2022
Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

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

This looks a lot better!

source Show resolved Hide resolved
source Show resolved Hide resolved
<ol>
<li><p>If the content attribute is not in any state (e.g. the attribute is missing and there
is no <i data-x="missing value default">missing value default</i>), or the content attribute
is in a state with no associated keyword value, then return the empty string.</p></li>
Copy link
Member

Choose a reason for hiding this comment

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

Use "no state" here for consistency with the other algorithm?

What is a state with no associated keyword value? Is that "no state" due to lack of an invalid value default?

Copy link
Member

Choose a reason for hiding this comment

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

I wonder if we should get rid of the "no state" state, and require invalid value default and missing value default for all enumerated attributes. I think it would make things simpler and less confusing.

Copy link
Member Author

Choose a reason for hiding this comment

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

What is a state with no associated keyword value? Is that "no state" due to lack of an invalid value default?

No, it's something like the inherit state for contenteditable

I wonder if we should get rid of the "no state" state, and require invalid value default and missing value default for all enumerated attributes. I think it would make things simpler and less confusing.

I was thinking of that. It would amount to introducing a lot of individual "default" states for a few attributes. In particular for: dir="", <link as="">, <meta http-equiv="">, formmethod=""/formenctype="", inputmode="", and enterkeyhint="". It's probably a clarity improvement but it's also a good bit of work.

Copy link
Member

Choose a reason for hiding this comment

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

OK. Considering the risk of introducing bugs, maybe it's not worth it, and it's sufficiently clear with this PR?

Copy link
Member

Choose a reason for hiding this comment

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

contenteditable isn't limited to only known values though. I'm not entirely convinced we ever hit this branch looking through the callers, but we could leave it as follow-up.

Copy link
Member Author

Choose a reason for hiding this comment

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

You're right about contenteditable. I think dir="" hits this branch though. It is limited to only known values, and has no invalid value default or missing value default, so if it's just omitted then it will end up in the "not in any state" case, and return the empty string. http://software.hixie.ch/utilities/js/live-dom-viewer/?saved=10361

source Show resolved Hide resolved
source Outdated Show resolved Hide resolved
source Show resolved Hide resolved
@zcorpan
Copy link
Member

zcorpan commented May 25, 2022

Also update crossOrigin to remove "limited to only known values"

@zcorpan
Copy link
Member

zcorpan commented May 25, 2022

Actually maybe we should have "limited to only known values" exist for both nullable and non-nullable enumerated attributes. I think that would be clearer for readers.

source Show resolved Hide resolved
<ol>
<li><p>If the content attribute is not in any state (e.g. the attribute is missing and there
is no <i data-x="missing value default">missing value default</i>), or the content attribute
is in a state with no associated keyword value, then return the empty string.</p></li>
Copy link
Member

Choose a reason for hiding this comment

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

contenteditable isn't limited to only known values though. I'm not entirely convinced we ever hit this branch looking through the callers, but we could leave it as follow-up.

source Outdated Show resolved Hide resolved
source Outdated Show resolved Hide resolved
@domenic
Copy link
Member Author

domenic commented Jun 3, 2022

Actually maybe we should have "limited to only known values" exist for both nullable and non-nullable enumerated attributes. I think that would be clearer for readers.

I think this is a good idea. Still to-do before we can merge this; I ran out of time for today.

@domenic
Copy link
Member Author

domenic commented Jun 6, 2022

OK, this is ready for re-review.

I realized that "limited to only known values" applies to IDL attributes, not content attributes. Thus, it should be stated where the crossOrigin IDL attributes are defined, not where the crossorigin="" content attribute is defined. And, it already is! So the only remaining fix for crossOrigin was to update the reflection for DOMString? to assert it was always "limited to only known values".

I also changed the DOMString? case to be symmetrical with the DOMString case, and return null when the attribute is in a state with no keyword, instead of the previous prose which returned null when in the missing value default state. For the only DOMString? case in the spec today (crossOrigin) they are equivalent, but for popup="" as discussed in openui/open-ui#533 (comment), we want the former behavior.

@domenic domenic merged commit 112cacc into main Jun 8, 2022
@domenic domenic deleted the fix-crossorigin-reflection branch June 8, 2022 16:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clarification Standard could be clearer
Development

Successfully merging this pull request may close these issues.

3 participants