Skip to content

Editorial updates to attribute reflection and enumerated attributes - #7956

Merged
domenic merged 6 commits into
mainfrom
fix-crossorigin-reflection
Jun 8, 2022
Merged

domenic merged 6 commits into
mainfrom
fix-crossorigin-reflection

Conversation

@domenic

@domenic domenic commented May 24, 2022 •

Copy link
Copy Markdown
Member

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 )

domenic added 2 commits May 24, 2022 16:02
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

@annevk annevk left a comment

Copy link
Copy Markdown
Member

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!

Comment thread source Resolved
Comment thread source Resolved
Comment thread source
<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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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

Comment thread source Resolved
Comment thread source Resolved
Comment thread source Resolved
@zcorpan

zcorpan commented May 25, 2022

Copy link
Copy Markdown
Member

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

@zcorpan

zcorpan commented May 25, 2022

Copy link
Copy Markdown
Member

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.

Comment thread source Resolved
Comment thread source
<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
Copy Markdown
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.

Comment thread source Resolved
Comment thread source Resolved
@domenic

domenic commented Jun 3, 2022

Copy link
Copy Markdown
Member Author

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

domenic commented Jun 6, 2022

Copy link
Copy Markdown
Member Author

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