canvas: force computation of css var containing calc() or var()
This commit is contained in:
parent
9e16fff2fa
commit
55cc2bdab3
1 changed files with 12 additions and 0 deletions
|
|
@ -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`<div style="position:absolute;width:var(${data.css})"></div>`
|
||||
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()
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue