Did IE10 change the definition of window.location.port?

dom, internet-explorer-10, javascript

Solution

This sounds like a bug, although I do not known of any such reported issue:

The HTML5: 2.6.2 Parsing URLs states that "[the port] is the substring matched by the production, if any."

Furthermore, the HTML5: 2.6.6 Interfaces for URL manipulation section gives an example input of `http://example.com/carrot#question%3f` which specifies that the port should be `""` - an (empty string).

UPDATE

This is a real bug: http://connect.microsoft.com/IE/feedback/details/817343/ie11-scripting-value-of-htmlanchorelement-host-differs-between-script-created-link-and-link-from-document

Problem

I noticed some JavaScript code that inspects `window.location.port` was breaking in IE10 Platform Preview 10.0.1008.16421 today. For instance, in IE10, go to http://www.microsoft.com. Open up the developer tools and type in `window.location.port` and it returns `80`. What happened? Why does IE10 suddenly return the integer `80` when all other IE browsers return the `""` (empty string) on the same site? IE10 also returns `80` in all of the downlevel modes. Compare the result for IE8/9 on http://www.microsoft.com : `window.location.port` is `""`! Any idea if this is a new behavior for IE10, a logged bug in the platform release, or a has-yet-to-be-reported bug?

Original source