@percy/dom 1.26.2-beta.0 → 1.26.3-beta.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.
Files changed (2) hide show
  1. package/dist/bundle.js +22 -2
  2. package/package.json +2 -2
package/dist/bundle.js CHANGED
@@ -195,6 +195,11 @@
195
195
  }
196
196
  return true;
197
197
  }
198
+ function createStyleResource(styleSheet) {
199
+ const styles = Array.from(styleSheet.cssRules).map(cssRule => cssRule.cssText).join('\n');
200
+ let resource = resourceFromText(uid(), 'text/css', styles);
201
+ return resource;
202
+ }
198
203
  function serializeCSSOM(_ref) {
199
204
  let {
200
205
  dom,
@@ -204,6 +209,7 @@
204
209
  } = _ref;
205
210
  // in-memory CSSOM into their respective DOM nodes.
206
211
  for (let styleSheet of dom.styleSheets) {
212
+ var _styleSheet$href;
207
213
  if (isCSSOM(styleSheet)) {
208
214
  let styleId = styleSheet.ownerNode.getAttribute('data-percy-element-id');
209
215
  let cloneOwnerNode = clone.querySelector(`[data-percy-element-id="${styleId}"]`);
@@ -215,6 +221,21 @@
215
221
  style.innerHTML = Array.from(styleSheet.cssRules).map(cssRule => cssRule.cssText).join('\n');
216
222
  cloneOwnerNode.parentNode.insertBefore(style, cloneOwnerNode.nextSibling);
217
223
  cloneOwnerNode.remove();
224
+ } else if ((_styleSheet$href = styleSheet.href) !== null && _styleSheet$href !== void 0 && _styleSheet$href.startsWith('blob:')) {
225
+ const styleLink = document.createElement('link');
226
+ styleLink.setAttribute('rel', 'stylesheet');
227
+ let resource = createStyleResource(styleSheet);
228
+ resources.add(resource);
229
+ styleLink.setAttribute('data-percy-blob-stylesheets-serialized', 'true');
230
+ styleLink.setAttribute('data-percy-serialized-attribute-href', resource.url);
231
+
232
+ /* istanbul ignore next: tested, but coverage is stripped */
233
+ if (clone.constructor.name === 'HTMLDocument' || clone.constructor.name === 'DocumentFragment') {
234
+ // handle document and iframe
235
+ clone.body.prepend(styleLink);
236
+ } else if (clone.constructor.name === 'ShadowRoot') {
237
+ clone.prepend(styleLink);
238
+ }
218
239
  }
219
240
  }
220
241
 
@@ -224,8 +245,7 @@
224
245
  const styleLink = document.createElement('link');
225
246
  styleLink.setAttribute('rel', 'stylesheet');
226
247
  if (!cache.has(sheet)) {
227
- const styles = Array.from(sheet.cssRules).map(cssRule => cssRule.cssText).join('\n');
228
- let resource = resourceFromText(uid(), 'text/css', styles);
248
+ let resource = createStyleResource(sheet);
229
249
  resources.add(resource);
230
250
  cache.set(sheet, resource.url);
231
251
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/dom",
3
- "version": "1.26.2-beta.0",
3
+ "version": "1.26.3-beta.0",
4
4
  "license": "MIT",
5
5
  "repository": {
6
6
  "type": "git",
@@ -35,5 +35,5 @@
35
35
  "devDependencies": {
36
36
  "interactor.js": "^2.0.0-beta.10"
37
37
  },
38
- "gitHead": "14191aa65d5da5190039ae0938c9fd8edab7cd28"
38
+ "gitHead": "2911cbf68c1745ba42acca4746bdeaad42dc98de"
39
39
  }