[whatwg] URL decomposition on HTMLAnchorElement interface
Boris Zbarsky
bzbarsky at MIT.EDU
Sat Mar 28 07:35:08 PDT 2009
Kartikaya Gupta wrote:
> Do you agree that null and empty string should behave differently for "search" and "hash"?
No, not really. Are they treated differently in current UAs (past null
being treated as "null", possibly)?
> To me, it doesn't make sense to treat null and the empty string differently for some components but not others.
Agreed that it would be confusing from a web developer point of view.
Of course from a URI point of view some URI components can be empty but
present or can be not present at all, as you point out above.
>> The latter. The Gecko-internal URI code does in fact throw on a lot of
>> these setters, and the HTMLAnchorElement methods catch and eat these
>> exceptions, very much on purpose.
>
> Ok. I'll assume there is valid reasoning behind that. Replace all the "throw"s with "be silently ignored" in my proposal.
For what it's worth, I suspect that the silent fail is somewhat
interoperably implemented already.
>> No, but you can pass it off to a helper application. In any case, my
>> comment above was more concerned with your proposal that one should be
>> able to create a non-authority http: URI than about unknown schemes.
>
> I don't think my proposal allowed creation of a non-authority http: URI. I said that 'Attempts to set "host" to null for a scheme known to require an authority should throw.' Since http is a scheme known to require an authority, you wouldn't be able to null out the authority.
Or set it to the empty string, which has the same effect. Your proposal
treats those differently.
> - Attempts to set "protocol" to null, the empty string, or anything containing invalid characters (i.e. not in the "scheme" production of RFC3986) should throw. Setting it to a scheme known to require an authority when the authority component is null should also throw. Setting it to a scheme known to require no authority when the authority component is non-null should also throw. Setting it to anything else should be allowed and should update the scheme component of the underlying URI.
Honestly, I can't think of a sane way to define a "protocol" setter that
changes from one URI "type" to another (type being "has authority",
"doesn't have authority", "unknown"). Actually, as far as Gecko is
concerned there are 5 different types; see the three constants defined
at
http://mxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsIStandardURL.idl#56
for three, plus "not a hierarchichal URI" (which never does the fixup
from scheme:foo to scheme://foo) and "unknown" (treated like "not a
hierarchical URI").
-Boris
More information about the whatwg
mailing list