@percy/dom 1.26.2-beta.0 → 1.26.2
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/dist/bundle.js +22 -2
- package/package.json +3 -3
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
|
-
|
|
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
|
|
3
|
+
"version": "1.26.2",
|
|
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": "
|
|
12
|
+
"tag": "latest"
|
|
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": "
|
|
38
|
+
"gitHead": "f97b6c463109420a4045dc0396bf9d429c2dc77d"
|
|
39
39
|
}
|