File tree 1 file changed +17
-0
lines changed
flow-server/src/main/resources/META-INF/frontend
1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change 1
1
import stripCssComments from 'strip-css-comments' ;
2
2
3
+ // Safari 15 - 16.3, polyfilled
4
+ const polyfilledSafari = CSSStyleSheet . toString ( ) . includes ( 'document.createElement' ) ;
5
+
3
6
const createLinkReferences = ( css , target ) => {
4
7
// Unresolved urls are written as '@import url(text);' or '@import "text";' to the css
5
8
// media query can be present on @media tag or on @import directive after url
@@ -42,9 +45,23 @@ const createLinkReferences = (css, target) => {
42
45
return styleCss ;
43
46
} ;
44
47
48
+ const addAdoptedStyleSafariPolyfill = ( sheet , target , first ) => {
49
+ if ( first ) {
50
+ target . adoptedStyleSheets = [ sheet , ...target . adoptedStyleSheets ] ;
51
+ } else {
52
+ target . adoptedStyleSheets = [ ...target . adoptedStyleSheets , sheet ] ;
53
+ }
54
+ return ( ) => {
55
+ target . adoptedStyleSheets = target . adoptedStyleSheets . filter ( ( ss ) => ss !== sheet ) ;
56
+ } ;
57
+ } ;
58
+
45
59
const addAdoptedStyle = ( cssText , target , first ) => {
46
60
const sheet = new CSSStyleSheet ( ) ;
47
61
sheet . replaceSync ( cssText ) ;
62
+ if ( polyfilledSafari ) {
63
+ return addAdoptedStyleSafariPolyfill ( sheet , target , first ) ;
64
+ }
48
65
if ( first ) {
49
66
target . adoptedStyleSheets . splice ( 0 , 0 , sheet ) ;
50
67
} else {
You can’t perform that action at this time.
0 commit comments