@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
@@ -1,5 +1,11 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.4.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [Added] - New function to fix CSS loading in Safari Percy tests ([#534](https://github.com/justeattakeaway/pie/pull/534)) by [@siggerzz](https://github.com/siggerzz)
8
+
3
9
  ## 0.3.0
4
10
 
5
11
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@justeattakeaway/pie-webc-core",
3
- "version": "0.3.0",
3
+ "version": "0.4.0",
4
4
  "description": "PIE design system base classes, mixins and utilities for web components",
5
5
  "type": "module",
6
6
  "main": "index.ts",
@@ -2,3 +2,4 @@ export * from './get-all-prop-combos';
2
2
  export * from './defs';
3
3
  export * from './rendering';
4
4
  export * from './components';
5
+ export * from './percy-lit-options';
@@ -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 }