Skip to content

Reflecting as non-empty URL should special-case empty string #859

@zcorpan

Description

@zcorpan

https://html.spec.whatwg.org/#reflecting-content-attributes-in-idl-attributes

If a reflecting IDL attribute is a DOMString attribute whose content attribute is defined to contain a URL, then on getting, the IDL attribute must parse the value of the content attribute relative to the element's node document and return the resulting URL string if that was successful, or the empty string otherwise; and on setting, must set the content attribute to the specified literal value. If the content attribute is absent, the IDL attribute must return the default value, if the content attribute has one, or else the empty string.

From web-platform-tests/wpt#2663 (comment)

A number of attributes are defined to take a non-empty URL, and they do nothing when the value is empty; e.g. <img src>, <track src> (but not e.g. <a href>). But when getting the IDL attribute it still resolves the empty string into a URL, which doesn't make any sense. I think we should fix reflecting to have different behavior between <img src="">.src and <a href="">.href such that the former returns the empty string.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions