diff --git a/src/Core/Style.js b/src/Core/Style.js index c158a8d9d0..12a2278864 100644 --- a/src/Core/Style.js +++ b/src/Core/Style.js @@ -8,7 +8,7 @@ import itowns_stroke_single_before from './StyleChunk/itowns_stroke_single_befor export const cacheStyle = new Cache(); const inv255 = 1 / 255; -const canvas = document.createElement('canvas'); +const canvas = (typeof document !== 'undefined') ? document.createElement('canvas') : {}; const style_properties = {}; function base_altitudeDefault(properties, coordinates = { z: 0 }) { @@ -710,14 +710,17 @@ class Style { const CustomStyle = { itowns_stroke_single_before, }; -const customStyleSheet = document.createElement('style'); + +const customStyleSheet = (typeof document !== 'undefined') ? document.createElement('style') : {}; customStyleSheet.type = 'text/css'; Object.keys(CustomStyle).forEach((key) => { customStyleSheet.innerHTML += `${CustomStyle[key]}\n\n`; }); -document.getElementsByTagName('head')[0].appendChild(customStyleSheet); +if (typeof document !== 'undefined') { + document.getElementsByTagName('head')[0].appendChild(customStyleSheet); +} const style = new Style();