diff --git a/src/client/widgets/common/canvas.js b/src/client/widgets/common/canvas.js index 46ce34e9..15434a37 100644 --- a/src/client/widgets/common/canvas.js +++ b/src/client/widgets/common/canvas.js @@ -111,8 +111,20 @@ class Canvas extends Widget { for (var data of this.constructor.cssVariables) { var val = style.getPropertyValue(data.css).trim() + + if (typeof val === 'string' && val.includes('(')) { + // property not computed because of calc() or var() in user style + // -> attempt to force calculation + var dummy = html`
` + this.container.appendChild(dummy) + let s = window.getComputedStyle(dummy) + val = parseInt(s.getPropertyValue('width')) + this.container.removeChild(dummy) + } + this.cssVars[data.js] = data.toJs ? data.toJs(val) : val + } this.fontFamily = style.getPropertyValue('font-family').trim()