Skip to content
This repository has been archived by the owner on Jun 29, 2023. It is now read-only.

Commit

Permalink
fix: demo pages in IE11 (#610)
Browse files Browse the repository at this point in the history
* demo page ie fixes

* no message

* no message

* no message

* no message

* ie11 check

* review fix for port

* review comment
  • Loading branch information
driskull authored Dec 6, 2019
1 parent 616f23b commit 56c7100
Showing 1 changed file with 47 additions and 20 deletions.
67 changes: 47 additions & 20 deletions src/demos/head.js
Original file line number Diff line number Diff line change
@@ -1,32 +1,59 @@
(function() {
const root = window.location.pathname.split("demos").shift();
const CSS = ["demos/demos.css", "build/calcite-app.css", "vendor/@esri/calcite-components/calcite.css"];

const SCRIPTS = [
{
src: "build/calcite-app.esm.js",
type: "module"
},
{
src: "build/calcite-app.js",
noModule: true
},
{
src: "vendor/@esri/calcite-components/calcite.esm.js",
type: "module"
},
{
src: "vendor/@esri/calcite-components/calcite.js",
noModule: true
}
];

// Assume server is running in a development environment if there is a port present in the URL and reload demo pages.
if (location.port) {
SCRIPTS.push({
src: "demos/demoPageReloader.js"
});
}

const IS_IE11 = /Trident.*rv[ :]*11\./.test(navigator.userAgent);

if (!IS_IE11) {
SCRIPTS.push({
src: "demos/toggles.js"
});
}

const ROOT = window.location.pathname.split("demos").shift();

function loadCss(url) {
let link = document.createElement("link");
link.rel = "stylesheet";
link.href = root + url;
link.href = ROOT + url;
document.head.appendChild(link);
}

function loadScript(url, options) {
let script = document.createElement("script");
if (options) {
Object.keys(options).forEach(function(key) {
script[key] = options[key];
});
}
script.src = root + url;
function loadScript(options) {
let scriptElement = document.createElement("script");

Object.keys(options).forEach(function(key) {
scriptElement[key] = key === "src" ? ROOT + options[key] : options[key];
});

document.head.appendChild(script);
document.head.appendChild(scriptElement);
}

loadCss("demos/demos.css");
loadCss("build/calcite-app.css");
loadCss("vendor/@esri/calcite-components/calcite.css");
loadScript("demos/demoPageReloader.js");
loadScript("demos/toggles.js");
loadScript("build/calcite-app.esm.js", { type: "module" });
loadScript("build/calcite-app.js", { noModule: true });
loadScript("vendor/@esri/calcite-components/calcite.esm.js", { type: "module" });
loadScript("vendor/@esri/calcite-components/calcite.js", { noModule: true });
CSS.forEach(loadCss);
SCRIPTS.forEach(loadScript);
})();

0 comments on commit 56c7100

Please sign in to comment.