Repository navigation
Description
I had an offline discussion with @mfreed7 regarding invalid, empty, and missing values which I wanted to relay here. Summary: I think popup (or, equivalently, popup="") should be allowed and should be equivalent to popup=popup. This does not cause forward-compat issues and makes the API more pleasant.
As background, remember that in HTML, attribute is the same as attribute="". There's nothing special about an attribute with no equal sign; it's just a shorthand for setting the attribute's value to the empty string. In particular there's no special booleanness vs. stringness for attributes; attribute values are strings, if the attribute is present at all. (Some parts of the spec will interpret certain attributes as booleans, by saying any string value, including the empty string, is treated as "true", and a missing attribute is treated as "false".)
Also as background, the popup attribute is slated to be an enumerated attribute. These have states and keywords. Keywords are the developer-facing API, and are the strings that appear inside the attribute value. States are the underlying model.
It looks like you have the following states: no-popup, popup, hint, and async. (Some or all of these might be renamed per #491 and #532, but I'll use these names for now.)
Then the question is how to map attribute presence/values to those states. It seems like there's broad agreement on the following:
- ASCII case-insensitive match for
hintwill map to the hint state - ASCII case-insensitive match for
asyncwill map to the async state - Missing attribute will map to the no-popup state. (In spec terms, this is the missing value default.)
- Garbage value (e.g.
foo) will map to the no-popup state, for forward compatibility. (In spec terms, this is the invalid value default.)
The question is what values should map to the popup state. I think the empty string should map to that state. That gives a nice DX, where the default behavior is expressed with just <div popup>. It has many precedents in other enumerated attributes: crossorigin, translate, hidden, contenteditable, and spellcheck are all cases where the empty string maps to some sort of "default useful state", and that default useful state is different than the missing value default.
Separately, you probably want an explicit non-empty string keyword to also map to the popup state. Let's call it popup, although per #491 both the state and keyword will probably be renamed.
There is another option, which is to just have the empty string be the only keyword mapping to the popup state. In that case the bikeshedding in #491 becomes much less urgent because the state name is a spec-internal concept and not part of the web developer-exposed interface. But all the example attributes I listed above have a non-empty string keyword as well as the empty string, and it's probably good to stay consistent.
Activity
mfreed7 commentedon May 18, 2022
Thanks for opening this issue @domenic. After listening to your arguments, I think I agree that it sounds like a good option to make
<div popup>mean the "standard" popup, equivalent to<div popup={#491}>. There were some concerns expressed over something likemyPopup.popup=truenot working, but I think those are probably outweighed by the convenience of the shorthand.One question: if we go this route, and recalling our resolution to only IDL-reflect valid values, what should this return?
It would seem "bad" to return the empty string, since that would round trip unfortunately:
It seems like
nullorundefinedwould be appropriate, but thoughts appreciated.domenic commentedon May 18, 2022
For reflection, you have two choices in the current spec:
The former seems like it would work well if you added a keyword for the no-popup state (e.g.,
popup=none). The latter seems like it would work well if you'd prefer not to do that.We could also explore adding new reflection variations, but I'm not sure that'd be necessary.
mfreed7 commentedon May 19, 2022
I think this makes the most sense to me. There'll need to be an enum value (there already is in Chromium) that means "none", so let's expose it directly.
I'm going to add this to the Agenda for next week, since we just resolved to rename the main case to
popup=auto. I'd like to get this one resolved also, so we can be done changing thepopupattribute.Proposed resolution: For the
popupattribute, an empty string ("") value should map topopup=auto. Also add a specific attribute value,popup=none, which behaves identically to when thepopupattribute is missing completely.Any objections?
zcorpan commentedon May 19, 2022
There's a third choice
crossOrigin has this setup, and also has the empty string being a state that's different from the missing value default.
Limited to only known values is good for feature-testing, so IMO it's a choice between having
noneas a synonym to missing attribute and the IDL returnnone, or no synonym and the IDL returns null.Returning null for the no-popup state and non-empty strings for the other states allows for truthy/falsy checks in JS, which seems a bit nicer in terms of developer ergonomics.
domenic commentedon May 20, 2022
Simon, I can't find that in the reflection section for some reason... Is crossOrigin just not well specified? Otherwise, yeah, that does seem a bit nicer.
mfreed7 commentedon May 20, 2022
Ohh I like the third choice. I do agree returning
nullis nicer for truthy/falsy checks. Given that's a possibility, here's a new proposed resolution:Proposed resolution: For the
popupattribute, an empty string ("") value should map topopup=auto. The IDL will be limited to only known values, meaning it will returnnullfor both invalid content attribute values and when thepopupattribute is missing entirely. Do not add a specific attribute value meaning "no popup", e.g.popup=none.zcorpan commentedon May 23, 2022
@domenic I think it falls under
but indeed it seems like there's a spec bug since
crossOriginis defined to be "limited to only known values" but also nullable.Searching for "
attribute DOMString?" in the spec it looks like it's onlycrossOriginthat's affected currently.mfreed7 commentedon May 23, 2022
I, perhaps incorrectly, assumed there was an implied "and the IDL attribute is limited to only known values" in that paragraph.
In non-spec language, here are my assumptions about what we want:
<div popup=auto>div.popup === 'auto'<div popup=AuTo>div.popup === 'auto'<div popup=hint>div.popup === 'hint'<div popup=async>div.popup === 'async'<div popup>div.popup === 'auto'<div popup="">div.popup === 'auto'<div>div.popup === null<div popup=foobar>div.popup === null<div popup=true>div.popup === null<div popup=none>div.popup === null<div popup=" auto "div.popup === nullmfreed7 commentedon May 23, 2022
Would this look like the right WebIDL for the above table?
There's no way to use
ReflectMissingorReflectInvalidsince we want them to benull, not a string. Right?zcorpan commentedon May 23, 2022
The table looks right to me.
As for the WebIDL,
ReflectandReflect*are non-standard chromium extensions I believe.The current spec text for reflecting nullable enumerated attributes says to return
nullfor the missing value default state, but we also want to return null for the invalid value default state, so the definition needs some massaging to allow for that.mfreed7 commentedon May 23, 2022
Right, of course. Thanks.
Is that something that seems easy to add to the spec? @domenic thoughts?
domenic commentedon May 24, 2022
Yeah, it's easy to add, and in fact something we need to do because currently the spec for
crossOriginis broken. I plan to do that sometime this week.domenic commentedon May 24, 2022
So I tried to work on a spec edit here and it appears crossOrigin is already working OK. Basically it appears nullable DOMString enumerated attributes are always implicitly "limited to known values". Whenever you are in the missing value default state, then you get back
null. So if you want to get backnullfor invalid values too, then just make sure your invalid value default is equal to your missing value default. (That is not whatcrossOrigindoes.)So for the table above I think you want the following spec:
DOMString?18 remaining items
mfreed7 commentedon Aug 19, 2022
Seems like we might already be close to consensus. I'll put this on the agenda for next week.
tbondwilkinson commentedon Aug 19, 2022
+1 to
popup="manual"for cases where the attribute is unclear.css-meeting-bot commentedon Aug 25, 2022
The Open UI Community Group just discussed
[popup] The popup attribute should allow the empty string value #533, and agreed to the following:RESOLVED: Change the Invalid Value Default for `popup` to be `manual`.The full IRC log of that discussion
<hdv> topic: [popup] The popup attribute should allow the empty string value #533<hdv> github: https://github.com//issues/533
<hdv> masonf: we talked about this one several times in the past… current behavior is if you assign a value to `popup` attribute that is invalid, then it is invalid and will result in no popup behavior to happen, so it will be a normal element, but won't have popup behavior
<hdv> masonf: we have been discussing the standard UA stylesheet for a popup
<hdv> masonf: the proposal is: if you use any attribute value that is invalid for popup, you would get the popup=manual behavior
<hdv> masonf: this doesn't break feature detection, you could still do that and the issue has code for how to do it
<JonathanNeal> q?
<hdv> masonf: so I would like to change from not supporting invalid popup values to supporting them as if they were popup=manual
<hdv> JonathanNeal: any comments?
<masonf> Proposed resolution: Change the Invalid Value Default for `popup` to be `manual`.
<dandclark> Seems reasonable to me.
<JonathanNeal> I find it reasonable, as well.
<hdv> bkardell_: I thought this was an interesting discussion, I wanted to think about it but didn't have time for it this week
<hdv> +1 seems reasonable to me
<hdv> JonathanNeal: let me phrase it differently, does anyone have objections ?
<hdv> bkardell_: only that we spent a long time debating and got to the opposite conclusion, I would like to understand why that was wrong… it's pretty minor, but I would not want us to revert again
<hdv> masonf: I think when we discussed it the first time we were kind of learning together how these kinds of attributes work… having looked at it more it looks like it is actually possible to feature detect
<hdv> masonf: I can also add Domenic was one of the people pushing for the old resolution and he agrees now with the new one
<JonathanNeal> q?
<hdv> JonathanNeal: based on that, would you want to go ahead with resolution?
<hdv> masonf: maybe we resolve now and we can always revisit later?
<flackr> +1 to the proposal
<hdv> JonathanNeal: feel free to jump in anyone if you feel against this resolution
<masonf> RESOLVED: Change the Invalid Value Default for `popup` to be `manual`.
scottaohara commentedon Aug 25, 2022
+1 to this as well. my only concern was that if
manualwould be the expected default behavior... but if someone is putting unsupported values into the attribute and they don't get the behavior they're expecting.... well... this will be a signal to them to check their values?mfreed7 commentedon Aug 25, 2022
Right. I like
manualfor two reasons:Change the `popup` invalid value default to "manual"
Change the `popup` invalid value default to "manual"
Change the `popup` invalid value default to "manual"
Change the `popup` invalid value default to "manual"
Change the `popup` invalid value default to "manual"
Bug 1787358 [wpt PR 35629] - Change the `popup` invalid value default…
Bug 1771337 [wpt PR 34217] - Convert `popup=popup` to `popup=auto` or…