Skip to content

Commit

Permalink
fix: Router.go string pathname parsing in IE (#401)
Browse files Browse the repository at this point in the history
  • Loading branch information
platosha authored and Viktor Lukashov committed Oct 4, 2019
1 parent 63ee8d6 commit b64acd8
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion docs/vaadin-router/demo/demo-shell.html
Original file line number Diff line number Diff line change
Expand Up @@ -7718,7 +7718,7 @@
Object.defineProperty(urlAnchor,"origin",{get:function get(){// IE11: on HTTP and HTTPS the default port is not included into
// window.location.origin, so won't include it here either.
var protocol=urlAnchor.protocol,port=urlAnchor.port,defaultHttp="http:"===protocol&&"80"===port,defaultHttps="https:"===protocol&&"443"===port,host=defaultHttp||defaultHttps?urlAnchor.hostname:urlAnchor.host;return"".concat(protocol,"//").concat(host)}});// IE11: HTMLAnchorElement pathname does not start with a leading slash
Object.defineProperty(urlAnchor,"pathname",{get:function get(){return urlAnchor.href.slice(urlAnchor.origin.length)}})}}}};Resolver.__createUrl=function(path,base){Resolver.__ensureUrlAvailableOrPolyfilled();if(isUrlAvailable){return new URL(path,base)}urlBase.href=base;urlAnchor.href=path.replace(/ /g,"%20");// IE11: only absolute href setting results in correct part properties
var getPathnameOrig=Object.getOwnPropertyDescriptor(Object.getPrototypeOf(urlAnchor),"pathname").get;Object.defineProperty(urlAnchor,"pathname",{get:function get(){var pathname=getPathnameOrig.apply(urlAnchor);return"/"!==pathname.charAt(0)?"/"+pathname:pathname}})}}}};Resolver.__createUrl=function(path,base){Resolver.__ensureUrlAvailableOrPolyfilled();if(isUrlAvailable){return new URL(path,base)}urlBase.href=base;urlAnchor.href=path.replace(/ /g,"%20");// IE11: only absolute href setting results in correct part properties
// (`protocol`, `host`, `port`, and such), otherwise they are empty.
urlAnchor.href=urlAnchor.href;// eslint-disable-line no-self-assign
return urlAnchor};exports.Resolver=Resolver;exports.Router=Router;Object.defineProperty(exports,"__esModule",{value:!0})});//# sourceMappingURL=vaadin-router.umd.js.map</script><script>// In order to make the demos work without the import statement there
Expand Down
9 changes: 8 additions & 1 deletion index.polyfilled.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,16 @@ Resolver.__ensureUrlAvailableOrPolyfilled = () => {
});

// IE11: HTMLAnchorElement pathname does not start with a leading slash
const getPathnameOrig = Object.getOwnPropertyDescriptor(
Object.getPrototypeOf(urlAnchor),
'pathname'
).get;
Object.defineProperty(urlAnchor, 'pathname', {
get: () => {
return urlAnchor.href.slice(urlAnchor.origin.length);
const pathname = getPathnameOrig.apply(urlAnchor);
return pathname.charAt(0) !== '/'
? '/' + pathname
: pathname;
}
});
}
Expand Down

0 comments on commit b64acd8

Please sign in to comment.