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

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

Closed
zcorpan opened this Issue Mar 11, 2016 · 5 comments

Comments

5 participants
@zcorpan
Member

zcorpan commented Mar 11, 2016

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.

@annevk

This comment has been minimized.

Show comment
Hide comment
@annevk

annevk Mar 11, 2016

Member

This seems reasonable to me, provided at least two implementers are willing to go at it.

Member

annevk commented Mar 11, 2016

This seems reasonable to me, provided at least two implementers are willing to go at it.

@zcorpan

This comment has been minimized.

Show comment
Hide comment
@zcorpan

zcorpan Mar 11, 2016

Member

cc @tkent-google (you filed web-platform-tests/wpt#2663) @sicking (you had opinions in https://lists.w3.org/Archives/Public/public-whatwg-archive/2010Mar/0067.html) -- are you OK with implementing this? I can fix the spec to address this issue and write new web-platform-tests to check this across all relevant elements, etc.

Member

zcorpan commented Mar 11, 2016

cc @tkent-google (you filed web-platform-tests/wpt#2663) @sicking (you had opinions in https://lists.w3.org/Archives/Public/public-whatwg-archive/2010Mar/0067.html) -- are you OK with implementing this? I can fix the spec to address this issue and write new web-platform-tests to check this across all relevant elements, etc.

@sicking

This comment has been minimized.

Show comment
Hide comment
@sicking

sicking Mar 11, 2016

Agreed, we should make the attribute reflect the actual used value. So for elements where "" is treated as "no value was provided" we should make the reflected attribute indicate that.

I'd say that more often than not, treating "" as "no value was provided" is the more expected behavior by developers. It'd be nice if we were somewhat consistent about that.

sicking commented Mar 11, 2016

Agreed, we should make the attribute reflect the actual used value. So for elements where "" is treated as "no value was provided" we should make the reflected attribute indicate that.

I'd say that more often than not, treating "" as "no value was provided" is the more expected behavior by developers. It'd be nice if we were somewhat consistent about that.

@foolip

This comment has been minimized.

Show comment
Hide comment
@foolip

foolip Mar 13, 2016

Member

It'd be nice if as many URLs possible have this behaviour, and that the current behavior is the exception where required for legacy. Otherwise the current behaviour will probably remain the default in bindings generators, and be very likely to spread to many new contexts by accident.

Member

foolip commented Mar 13, 2016

It'd be nice if as many URLs possible have this behaviour, and that the current behavior is the exception where required for legacy. Otherwise the current behaviour will probably remain the default in bindings generators, and be very likely to spread to many new contexts by accident.

@tkent-google

This comment has been minimized.

Show comment
Hide comment
@tkent-google

tkent-google Mar 14, 2016

Contributor

I'm ok with the change.

Contributor

tkent-google commented Mar 14, 2016

I'm ok with the change.

zcorpan added a commit that referenced this issue Mar 14, 2016

Fix #859: Special-case empty string in reflect as URL
Attributes that take a "valid non-empty URL potentially surrounded
by spaces" and have the empty string as value should also have the
reflecting IDL attribute return the empty string.

@annevk annevk closed this in f09dbee Mar 15, 2016

zcorpan added a commit to web-platform-tests/wpt that referenced this issue Sep 5, 2016

Refactor and fix HTMLTrackElement/src.html
Reflecting USVString attributes containing a URL should return
the empty string if the content attribute's value is empty.
Ref. whatwg/html#859

A single \u0000 character gets stripped by the URL parser;
"Remove any leading and trailing C0 controls and space from input."

Fixes #2125. Closes #2663.

zcorpan added a commit that referenced this issue Sep 6, 2016

annevk added a commit that referenced this issue Sep 6, 2016

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment