mirror of
https://github.com/niklasvh/html2canvas.git
synced 2023-08-10 21:13:10 +03:00
test(NodeContainer): Fix condition test.
This commit is contained in:
parent
8350c1df85
commit
c703cba3fd
@ -274,19 +274,25 @@ const getImage = (node: HTMLElement | SVGSVGElement, resourceLoader: ResourceLoa
|
||||
node instanceof SVGSVGElement
|
||||
) {
|
||||
const percentValueTest: RegExp = /^[0-9]{1,3}\%$/i;
|
||||
|
||||
const widthAttribute: string = node.getAttribute('width') || '';
|
||||
const widthStyle: string = node.style.width || '';
|
||||
const heightAttribute: string = node.getAttribute('width') || '';
|
||||
const heightStyle: string = node.style.width || '';
|
||||
|
||||
if (
|
||||
percentValueTest.test(node.getAttribute('width')) ||
|
||||
percentValueTest.test(node.getAttribute('height')) ||
|
||||
percentValueTest.test(node.style.width) ||
|
||||
percentValueTest.test(node.style.height)
|
||||
percentValueTest.test(widthAttribute) ||
|
||||
percentValueTest.test(widthStyle) ||
|
||||
percentValueTest.test(heightAttribute) ||
|
||||
percentValueTest.test(heightStyle)
|
||||
) {
|
||||
if (!node.clientWidth && !node.clientHeight && node.parentNode) {
|
||||
const parentStyle = window.getComputedStyle(node.parentNode);
|
||||
node.setAttribute('width', parentStyle.width);
|
||||
node.setAttribute('height', parentStyle.height);
|
||||
node.setAttribute('width', parentStyle.width.toString());
|
||||
node.setAttribute('height', parentStyle.height.toString());
|
||||
} else {
|
||||
node.setAttribute('width', node.clientWidth);
|
||||
node.setAttribute('height', node.clientHeight);
|
||||
node.setAttribute('width', node.clientWidth.toString());
|
||||
node.setAttribute('height', node.clientHeight.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user