Skip to content

Commit

Permalink
refactor(Style): instantiate canvas when no document
Browse files Browse the repository at this point in the history
  • Loading branch information
ftoromanoff committed Apr 12, 2023
1 parent 4ca93a9 commit b20916f
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/Core/Style.js
Expand Up @@ -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 }) {
Expand Down Expand Up @@ -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();

Expand Down

0 comments on commit b20916f

Please sign in to comment.