Skip to content

Commit

Permalink
fix(core): allow to init Framework7 more than once if runs on server-…
Browse files Browse the repository at this point in the history
…side
  • Loading branch information
nolimits4web committed Feb 15, 2021
1 parent ca6aaa7 commit 964af1e
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/core/components/app/app-class.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import loadModule from './load-module';
class Framework7 extends Framework7Class {
constructor(params = {}) {
super(params);
if (Framework7.instance) {
// eslint-disable-next-line
if (Framework7.instance && typeof window !== 'undefined') {
throw new Error("Framework7 is already initialized and can't be initialized more than once");
}
const device = getDevice({ userAgent: params.userAgent || undefined });
Expand All @@ -28,8 +29,8 @@ class Framework7 extends Framework7Class {
app.device = device;
app.support = support;

const window = getWindow();
const document = getDocument();
const w = getWindow();
const d = getDocument();

Framework7.instance = app;

Expand All @@ -39,7 +40,7 @@ class Framework7 extends Framework7Class {
id: 'io.framework7.myapp',
el: 'body',
theme: 'auto',
language: window.navigator.language,
language: w.navigator.language,
routes: [],
name: 'Framework7',
lazyModulesPath: null,
Expand Down Expand Up @@ -84,7 +85,7 @@ class Framework7 extends Framework7Class {

// Initially passed parameters
passedParams,
online: window.navigator.onLine,
online: w.navigator.onLine,
});

if (params.store) app.params.store = params.store;
Expand All @@ -103,7 +104,7 @@ class Framework7 extends Framework7Class {
// Init
if (app.params.init) {
if (device.cordova && app.params.initOnDeviceReady) {
$(document).on('deviceready', () => {
$(d).on('deviceready', () => {
app.init();
});
} else {
Expand Down

0 comments on commit 964af1e

Please sign in to comment.