|
@ -37,6 +37,21 @@ const SIZING_STYLE = [ |
|
|
let computedStyleCache = {}; |
|
|
let computedStyleCache = {}; |
|
|
let hiddenTextarea; |
|
|
let hiddenTextarea; |
|
|
|
|
|
|
|
|
|
|
|
function computedStyle(node) { |
|
|
|
|
|
return window.getComputedStyle ? getComputedStyle(node) : node.currentStyle; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
function getStylePropertyValue(style, prop) { |
|
|
|
|
|
let value; |
|
|
|
|
|
if (style) { |
|
|
|
|
|
value = window.getComputedStyle ? |
|
|
|
|
|
style.getPropertyValue(prop) |
|
|
|
|
|
: |
|
|
|
|
|
style[prop.replace(/-(\w)/gi, (word, letter) => letter.toUpperCase())]; |
|
|
|
|
|
} |
|
|
|
|
|
return value; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
function calculateNodeStyling(node, useCache = false) { |
|
|
function calculateNodeStyling(node, useCache = false) { |
|
|
const nodeRef = ( |
|
|
const nodeRef = ( |
|
|
node.getAttribute('id') || |
|
|
node.getAttribute('id') || |
|
@ -48,26 +63,26 @@ function calculateNodeStyling(node, useCache = false) { |
|
|
return computedStyleCache[nodeRef]; |
|
|
return computedStyleCache[nodeRef]; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
const style = window.getComputedStyle(node); |
|
|
const style = computedStyle(node); |
|
|
|
|
|
|
|
|
const boxSizing = ( |
|
|
const boxSizing = ( |
|
|
style.getPropertyValue('box-sizing') || |
|
|
getStylePropertyValue(style, 'box-sizing') || |
|
|
style.getPropertyValue('-moz-box-sizing') || |
|
|
getStylePropertyValue(style, '-moz-box-sizing') || |
|
|
style.getPropertyValue('-webkit-box-sizing') |
|
|
getStylePropertyValue(style, '-webkit-box-sizing') |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
const paddingSize = ( |
|
|
const paddingSize = ( |
|
|
parseFloat(style.getPropertyValue('padding-bottom')) + |
|
|
parseFloat(getStylePropertyValue(style, 'padding-bottom')) + |
|
|
parseFloat(style.getPropertyValue('padding-top')) |
|
|
parseFloat(getStylePropertyValue(style, 'padding-top')) |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
const borderSize = ( |
|
|
const borderSize = ( |
|
|
parseFloat(style.getPropertyValue('border-bottom-width')) + |
|
|
parseFloat(getStylePropertyValue(style, 'border-bottom-width')) + |
|
|
parseFloat(style.getPropertyValue('border-top-width')) |
|
|
parseFloat(getStylePropertyValue(style, 'border-top-width')) |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
const sizingStyle = SIZING_STYLE |
|
|
const sizingStyle = SIZING_STYLE |
|
|
.map(name => `${name}:${style.getPropertyValue(name)}`) |
|
|
.map(name => `${name}:${getStylePropertyValue(style, name)}`) |
|
|
.join(';'); |
|
|
.join(';'); |
|
|
|
|
|
|
|
|
const nodeInfo = { |
|
|
const nodeInfo = { |
|
|