sveltejs/sapper

Utilise <base> tag in goto() in case of IE11

Closed this issue · 1 comments

When trying to use goto() in IE11, whole page will reload instead of navigation. As i understand this is because document.baseURI is undefined in IE11, so goto() function logic falls back to location.href = href;.

This can of course be fixed by setting document.baseURI in IE to value of <base> tag that sapper adds, but maybe this should be added in sapper code base.

In goto() definition new URL is made with
const target = select_target(new URL(href, document.baseURI)); This can maybe be changed to call function like this instead of document.baseURI directly:

function getBaseURI() {
  if (document.baseURI) return document.baseURI;
  const base = document.getElementsByTagName('base');
  if (base.length > 0) return base[0].href;
  return document.URL;
}

This should be fixed in 0.28.9.