From dd6d8856eca820a13a0990c467b9e531433fd4a9 Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Thu, 15 Jul 2021 17:15:47 +0800 Subject: [PATCH] fix: svg d path getting truncated on copy (#2589) --- src/dom/document-cloner.ts | 9 +++++++-- tests/reftests/images/svg/native_only.html | 8 ++++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/dom/document-cloner.ts b/src/dom/document-cloner.ts index 07bc560..d520e01 100644 --- a/src/dom/document-cloner.ts +++ b/src/dom/document-cloner.ts @@ -443,12 +443,17 @@ const iframeLoader = (iframe: HTMLIFrameElement): Promise => }); }; +const ignoredStyleProperties = [ + 'all', // #2476 + 'd', // #2483 + 'content' // Safari shows pseudoelements if content is set +]; + export const copyCSSStyles = (style: CSSStyleDeclaration, target: T): T => { // Edge does not provide value for cssText for (let i = style.length - 1; i >= 0; i--) { const property = style.item(i); - // Safari shows pseudoelements if content is set - if (property !== 'content' && property !== 'all') { + if (ignoredStyleProperties.indexOf(property) === -1) { target.style.setProperty(property, style.getPropertyValue(property)); } } diff --git a/tests/reftests/images/svg/native_only.html b/tests/reftests/images/svg/native_only.html index 341258c..af50eac 100644 --- a/tests/reftests/images/svg/native_only.html +++ b/tests/reftests/images/svg/native_only.html @@ -40,5 +40,13 @@ canvas + + + + + + + +