diff --git a/.babelrc b/.babelrc index 10a91da0e..37b74fe1c 100644 --- a/.babelrc +++ b/.babelrc @@ -1,5 +1,7 @@ { + "plugins": ["@babel/proposal-class-properties"], "presets": [["@babel/env", { + "useBuiltIns": false, "targets": { "ie": "11" } diff --git a/package.json b/package.json index 6bb4b980c..94ae15c57 100644 --- a/package.json +++ b/package.json @@ -78,6 +78,8 @@ ], "devDependencies": { "@babel/cli": "7.12.1", + "@babel/plugin-proposal-class-properties": "7.12.1", + "@babel/plugin-transform-classes": "7.12.1", "@babel/preset-env": "7.12.1", "@babel/types": "^7.12.6", "@cortex-js/prettier-config": "^1.0.0", diff --git a/src/public/mathfield-element.ts b/src/public/mathfield-element.ts index 4968d83ac..efad78d8f 100644 --- a/src/public/mathfield-element.ts +++ b/src/public/mathfield-element.ts @@ -1150,8 +1150,9 @@ declare global { MathfieldElement: typeof MathfieldElement; } } - -if (!window.customElements.get('math-field')) { - window.MathfieldElement = MathfieldElement; - window.customElements.define('math-field', MathfieldElement); +if (typeof window != 'undefined' && window.customElements) { + if (!window.customElements.get('math-field')) { + window.MathfieldElement = MathfieldElement; + window.customElements.define('math-field', MathfieldElement); + } }