( nativeNode: T, clonedNode: T, options: Options, )
| 120 | } |
| 121 | |
| 122 | function cloneCSSStyle<T extends HTMLElement>( |
| 123 | nativeNode: T, |
| 124 | clonedNode: T, |
| 125 | options: Options, |
| 126 | ) { |
| 127 | const targetStyle = clonedNode.style |
| 128 | if (!targetStyle) { |
| 129 | return |
| 130 | } |
| 131 | |
| 132 | const sourceStyle = window.getComputedStyle(nativeNode) |
| 133 | if (sourceStyle.cssText) { |
| 134 | targetStyle.cssText = sourceStyle.cssText |
| 135 | targetStyle.transformOrigin = sourceStyle.transformOrigin |
| 136 | } else { |
| 137 | getStyleProperties(options).forEach((name) => { |
| 138 | let value = sourceStyle.getPropertyValue(name) |
| 139 | if (name === 'font-size' && value.endsWith('px')) { |
| 140 | const reducedFont = |
| 141 | Math.floor(parseFloat(value.substring(0, value.length - 2))) - 0.1 |
| 142 | value = `${reducedFont}px` |
| 143 | } |
| 144 | |
| 145 | if ( |
| 146 | isInstanceOfElement(nativeNode, HTMLIFrameElement) && |
| 147 | name === 'display' && |
| 148 | value === 'inline' |
| 149 | ) { |
| 150 | value = 'block' |
| 151 | } |
| 152 | |
| 153 | if (name === 'd' && clonedNode.getAttribute('d')) { |
| 154 | value = `path(${clonedNode.getAttribute('d')})` |
| 155 | } |
| 156 | |
| 157 | targetStyle.setProperty( |
| 158 | name, |
| 159 | value, |
| 160 | sourceStyle.getPropertyPriority(name), |
| 161 | ) |
| 162 | }) |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | function cloneInputValue<T extends HTMLElement>(nativeNode: T, clonedNode: T) { |
| 167 | if (isInstanceOfElement(nativeNode, HTMLTextAreaElement)) { |
no test coverage detected
searching dependent graphs…