@percy/dom 1.28.7 → 1.28.8-beta.1

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.
Files changed (2) hide show
  1. package/dist/bundle.js +36 -27
  2. package/package.json +3 -3
package/dist/bundle.js CHANGED
@@ -220,33 +220,42 @@
220
220
  warnings
221
221
  } = _ref;
222
222
  // in-memory CSSOM into their respective DOM nodes.
223
- for (let styleSheet of dom.styleSheets) {
224
- var _styleSheet$href;
225
- if (isCSSOM(styleSheet)) {
226
- let styleId = styleSheet.ownerNode.getAttribute('data-percy-element-id');
227
- let cloneOwnerNode = clone.querySelector(`[data-percy-element-id="${styleId}"]`);
228
- if (styleSheetsMatch(styleSheet, styleSheetFromNode(cloneOwnerNode))) continue;
229
- let style = document.createElement('style');
230
- style.type = 'text/css';
231
- style.setAttribute('data-percy-element-id', styleId);
232
- style.setAttribute('data-percy-cssom-serialized', 'true');
233
- style.innerHTML = Array.from(styleSheet.cssRules).map(cssRule => cssRule.cssText).join('\n');
234
- cloneOwnerNode.parentNode.insertBefore(style, cloneOwnerNode.nextSibling);
235
- cloneOwnerNode.remove();
236
- } else if ((_styleSheet$href = styleSheet.href) !== null && _styleSheet$href !== void 0 && _styleSheet$href.startsWith('blob:')) {
237
- const styleLink = document.createElement('link');
238
- styleLink.setAttribute('rel', 'stylesheet');
239
- let resource = createStyleResource(styleSheet);
240
- resources.add(resource);
241
- styleLink.setAttribute('data-percy-blob-stylesheets-serialized', 'true');
242
- styleLink.setAttribute('data-percy-serialized-attribute-href', resource.url);
243
-
244
- /* istanbul ignore next: tested, but coverage is stripped */
245
- if (clone.constructor.name === 'HTMLDocument' || clone.constructor.name === 'DocumentFragment') {
246
- // handle document and iframe
247
- clone.body.prepend(styleLink);
248
- } else if (clone.constructor.name === 'ShadowRoot') {
249
- clone.prepend(styleLink);
223
+ let styleSheets = null;
224
+ // catch error in case styleSheets property is not available (overwritten to throw error)
225
+ try {
226
+ styleSheets = dom.styleSheets;
227
+ } catch {
228
+ warnings.add('Skipping `styleSheets` as it is not supported.');
229
+ }
230
+ if (styleSheets) {
231
+ for (let styleSheet of styleSheets) {
232
+ var _styleSheet$href;
233
+ if (isCSSOM(styleSheet)) {
234
+ let styleId = styleSheet.ownerNode.getAttribute('data-percy-element-id');
235
+ let cloneOwnerNode = clone.querySelector(`[data-percy-element-id="${styleId}"]`);
236
+ if (styleSheetsMatch(styleSheet, styleSheetFromNode(cloneOwnerNode))) continue;
237
+ let style = document.createElement('style');
238
+ style.type = 'text/css';
239
+ style.setAttribute('data-percy-element-id', styleId);
240
+ style.setAttribute('data-percy-cssom-serialized', 'true');
241
+ style.innerHTML = Array.from(styleSheet.cssRules).map(cssRule => cssRule.cssText).join('\n');
242
+ cloneOwnerNode.parentNode.insertBefore(style, cloneOwnerNode.nextSibling);
243
+ cloneOwnerNode.remove();
244
+ } else if ((_styleSheet$href = styleSheet.href) !== null && _styleSheet$href !== void 0 && _styleSheet$href.startsWith('blob:')) {
245
+ const styleLink = document.createElement('link');
246
+ styleLink.setAttribute('rel', 'stylesheet');
247
+ let resource = createStyleResource(styleSheet);
248
+ resources.add(resource);
249
+ styleLink.setAttribute('data-percy-blob-stylesheets-serialized', 'true');
250
+ styleLink.setAttribute('data-percy-serialized-attribute-href', resource.url);
251
+
252
+ /* istanbul ignore next: tested, but coverage is stripped */
253
+ if (clone.constructor.name === 'HTMLDocument' || clone.constructor.name === 'DocumentFragment') {
254
+ // handle document and iframe
255
+ clone.body.prepend(styleLink);
256
+ } else if (clone.constructor.name === 'ShadowRoot') {
257
+ clone.prepend(styleLink);
258
+ }
250
259
  }
251
260
  }
252
261
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/dom",
3
- "version": "1.28.7",
3
+ "version": "1.28.8-beta.1",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -9,7 +9,7 @@
9
9
  },
10
10
  "publishConfig": {
11
11
  "access": "public",
12
- "tag": "latest"
12
+ "tag": "beta"
13
13
  },
14
14
  "main": "dist/bundle.js",
15
15
  "browser": "dist/bundle.js",
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "interactor.js": "^2.0.0-beta.10"
37
37
  },
38
- "gitHead": "d920b185772c020b9df6719142623844aeccb9af"
38
+ "gitHead": "d31a9746c7be6d74db284b8f30c3248d2bba916e"
39
39
  }