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

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

Projects

None yet

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 w3c/web-platform-tests#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
Member
annevk commented Mar 11, 2016

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

@zcorpan
Member
zcorpan commented Mar 11, 2016

cc @tkent-google (you filed w3c/web-platform-tests#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
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
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

I'm ok with the change.

@zcorpan zcorpan added a commit that referenced this issue Mar 14, 2016
@zcorpan zcorpan 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.
ad13533
@annevk annevk pushed a commit that closed this issue Mar 15, 2016
@zcorpan zcorpan 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.
f09dbee
@annevk annevk closed this in f09dbee Mar 15, 2016
@zcorpan zcorpan added a commit to w3c/web-platform-tests that referenced this issue Sep 5, 2016
@zcorpan zcorpan 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.
d5221cf
@zcorpan zcorpan referenced this issue in w3c/web-platform-tests Sep 5, 2016
Merged

Refactor and fix HTMLTrackElement/src.html #3639

@zcorpan zcorpan added a commit that referenced this issue Sep 6, 2016
@zcorpan zcorpan Revert "Fix #859: Special-case empty string in reflect as URL"
This reverts commit f09dbee.

Fixes #1739.
095bacb
@annevk annevk added a commit that referenced this issue Sep 6, 2016
@zcorpan @annevk zcorpan + annevk Revert "Fix #859: Special-case empty string in reflect as URL"
This reverts commit f09dbee.

Fixes #1739.
85227d2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment