Skip to content
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
Closed

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

zcorpan opened this issue Mar 11, 2016 · 5 comments

Comments

@zcorpan
Copy link
Member

@zcorpan 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
Copy link
Member

@annevk annevk commented Mar 11, 2016

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

@zcorpan
Copy link
Member Author

@zcorpan 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
Copy link

@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
Copy link
Member

@foolip 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
Copy link
Collaborator

@tkent-google tkent-google commented Mar 14, 2016

I'm ok with the change.

zcorpan added a commit that referenced this issue Mar 14, 2016
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
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
This reverts commit f09dbee.

Fixes #1739.
annevk added a commit that referenced this issue Sep 6, 2016
This reverts commit f09dbee.

Fixes #1739.
alice added a commit to alice/html that referenced this issue Jan 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.