Repro step: 1. In JS console, type var u = new URL("http://host.tld:8888/path") u.host 2.observe that result is "host.tld:8888" 3.type u.host = "newhost.tld" u.host 4. observe that result is "newhost.tld" Per the specification the port is not changed, therefore the result should be "newest.tld:8888", which is what FF and Chrome do.
This was originally filed on Chrome, while the spec seems to indicate Chrome and FF's behavior is the expected one. https://code.google.com/p/chromium/issues/detail?id=551901#c8 (+annevk for potential spec issue)
Looks like the spec now has clarification that the port should not be overridden if the given value for the .host does not have port part: https://github.com/whatwg/url/commit/99a85f77e0edf2bcc9f73183eba6c50ef9706ded
Kinuko, is it true that this change was never done for Chrome? If so there may be less priority to change the behavior for WebKit (I am not sure what Firefox behavior here is though).
Created attachment 404241 [details] Patch
Created attachment 404255 [details] Patch
Comment on attachment 404255 [details] Patch According to https://wpt.fyi/results/url/url-setters.html?label=experimental&label=master&aligned we currently match chrome and Firefox is the only browser following the spec/passing the wpt. I think that is justification to not change this unless Chrome does. Admittedly Firefox's behavior makes intuitive sense so I'd be willing to change if there's a consensus.
Created attachment 404543 [details] Patch
(In reply to Alex Christensen from comment #6) > Comment on attachment 404255 [details] > Patch > > According to > https://wpt.fyi/results/url/url-setters. > html?label=experimental&label=master&aligned we currently match chrome and > Firefox is the only browser following the spec/passing the wpt. I think > that is justification to not change this unless Chrome does. The patch to change the behavior just landed: https://chromium-review.googlesource.com/c/chromium/src/+/2300103> Admittedly >Firefox's behavior makes intuitive sense so I'd be willing to > change if there's a consensus. Good to know!
Committed r264516: <https://trac.webkit.org/changeset/264516> All reviewed patches have been landed. Closing bug and clearing flags on attachment 404543 [details].
<rdar://problem/65729794>