@justeattakeaway/pie-webc-core 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
///*
|
|
2
|
+
///* This code snippet was provided by Percy as a way to get our Lit components working correctly when running against the Safari browser.
|
|
3
|
+
///* Safari blocks requests coming from localhost, resulting in our CSS not loading when requested.
|
|
4
|
+
///* This function is passed to Percy and executed against the serialised DOM to rewrite all 'localhost' urls to 'render.percy.local'.
|
|
5
|
+
///* This is a temporary workaround, and a long-term solution will be implemented by Percy at a later date.
|
|
6
|
+
///*
|
|
7
|
+
const percyOptions = {
|
|
8
|
+
domTransformation: (documentElement: any) => {
|
|
9
|
+
function updateLinks(root : any) {
|
|
10
|
+
root.querySelectorAll('[data-percy-adopted-stylesheets-serialized]').forEach((link : any) => {
|
|
11
|
+
console.log(link);
|
|
12
|
+
let href = link.getAttribute('data-percy-serialized-attribute-href');
|
|
13
|
+
href = href.replace(/localhost[:\d+]*/, 'render.percy.local');
|
|
14
|
+
link.setAttribute('data-percy-serialized-attribute-href', href);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
root.querySelectorAll('[data-percy-shadow-host]')
|
|
18
|
+
.forEach((shadowHost : any) => {
|
|
19
|
+
console.log(shadowHost);
|
|
20
|
+
if (shadowHost?.shadowRoot)
|
|
21
|
+
updateLinks(shadowHost.shadowRoot);
|
|
22
|
+
}
|
|
23
|
+
);
|
|
24
|
+
}
|
|
25
|
+
updateLinks(documentElement);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const getLitPercyOptions = () => {
|
|
30
|
+
const options = {
|
|
31
|
+
domTransformation: percyOptions.domTransformation.toString()
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
return options;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export { getLitPercyOptions }
|