File is correct in that case, because you didn't change the URL the document is constructed with. When I load a document from the file system, relative URLs have protocol file; when I load a document over HTTP, relative URLs have protocol http. In jsdom you can do both. Don't break the file case.

On Jan 27, 2014, at 8:21, "Salvatore" <notifications@github.com<mailto:notifications@github.com>> wrote:


In lib/jsdom/level2/html.js:

> @@ -1315,6 +1315,13 @@ define('HTMLAnchorElement', {
>      get host() {
>        return URL.parse(this.href).host;
>      },
> +    get port() {
> +      return URL.parse(this.href).port;
> +    },
> +    get protocol() {
> +      var protocol = URL.parse(this.href).protocol;
> +      return (protocol == null) ? ':' : protocol.replace('file', 'http');


The replace is to handle URL.parse returning 'file:' in the case of HREF="./pix/submit.gif", which should return 'http:' (as chrome/safari/firefox did). I guess it would fail if href="file://somepath". I'll add one more assert in the tests for that condition and update the replace to only change it when there isn't a specific protocol in the href.

-
Reply to this email directly or view it on GitHub<https://github.com/tmpvar/jsdom/pull/733/files#r9188035>.