Skip to content

Commit

Permalink
fix: disable box-shadow rendering on ios/safari (#634)
Browse files Browse the repository at this point in the history
* disable box-shadow rendering on ios/safari

* Create chilly-elephants-retire.md
  • Loading branch information
riccardoperra authored May 18, 2024
1 parent 96e1ba5 commit 7f715bd
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .changeset/chilly-elephants-retire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@codeimage/dom-export": patch
---

fix: disable box-shadow rendering on ios/safari
4 changes: 2 additions & 2 deletions packages/dom-export/src/lib/cloneNode.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {isIOS} from '@solid-primitives/platform';
import {isIOS, isSafari} from '@solid-primitives/platform';
import {clonePseudoElements} from './clonePseudoElements';
import {copyFont, copyUserComputedStyleFast} from './cloneStyle';
import {getBlobFromURL} from './getBlobFromURL';
Expand Down Expand Up @@ -119,7 +119,7 @@ function cloneCSSStyle<T extends HTMLElement>(
}

const boxShadow = sourceStyle.getPropertyValue('boxShadow');
if (boxShadow !== 'none' && isIOS) {
if (boxShadow !== 'none' && (isIOS || isSafari)) {
clonedNode.setAttribute(
'style',
`${clonedNode.getAttribute('style')};box-shadow:none!important;`,
Expand Down
4 changes: 4 additions & 0 deletions packages/dom-export/src/lib/clonePseudoElements.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import {isIOS, isSafari} from '@solid-primitives/platform';
import {toArray, uuid} from './util';

type Pseudo = ':before' | ':after';
Expand All @@ -24,6 +25,9 @@ function getPseudoElementStyle(
style: CSSStyleDeclaration,
): Text {
const selector = `.${className}:${pseudo}`;
if (isIOS || isSafari) {
style.boxShadow = 'unset';
}
const cssText = style.cssText
? formatCSSText(style)
: formatCSSProperties(style);
Expand Down

0 comments on commit 7f715bd

Please sign in to comment.