Skip to content

Commit

Permalink
fix(angular): Fix angular SSR issues
Browse files Browse the repository at this point in the history
  • Loading branch information
theiliad committed Sep 11, 2019
1 parent 13193e8 commit 86aa9d3
Showing 1 changed file with 20 additions and 18 deletions.
38 changes: 20 additions & 18 deletions packages/core/src/polyfills.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
(function() {
if (typeof window["CustomEvent"] === "function") { return false; }
if (typeof window !== "undefined") {
(function() {
if (typeof window["CustomEvent"] === "function") { return false; }

function CustomEvent(event, params) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
const evt = document.createEvent("CustomEvent");
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
}
function CustomEvent(event, params) {
params = params || { bubbles: false, cancelable: false, detail: undefined };
const evt = document.createEvent("CustomEvent");
evt.initCustomEvent(event, params.bubbles, params.cancelable, params.detail);
return evt;
}

CustomEvent.prototype = window["Event"].prototype;
window["CustomEvent"] = CustomEvent;
})();

CustomEvent.prototype = window["Event"].prototype;
window["CustomEvent"] = CustomEvent;
})();
// Avoid multiple instances of babel-polyfill
function idempotentBabelPolyfill() {
if ((typeof global !== "undefined" && !global["_babelPolyfill"]) || !window["_babelPolyfill"]) {
return require("babel-polyfill");
}

// Avoid multiple instances of babel-polyfill
function idempotentBabelPolyfill() {
if (!global["_babelPolyfill"] && (typeof window === "undefined" || !window["_babelPolyfill"])) {
return require("babel-polyfill");
return null;
}

return null;
idempotentBabelPolyfill();
}

idempotentBabelPolyfill();

0 comments on commit 86aa9d3

Please sign in to comment.