Skip to content

The popup attribute should allow the empty string value #533

@domenic

Description

@domenic

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 hint will map to the hint state
  • ASCII case-insensitive match for async will 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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    popoverThe Popover API

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions