@percy/dom 1.30.8 → 1.30.9-alpha.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/dist/bundle.js +53 -3
- package/package.json +3 -3
package/dist/bundle.js
CHANGED
|
@@ -314,9 +314,21 @@
|
|
|
314
314
|
/* istanbul ignore next: tested, but coverage is stripped */
|
|
315
315
|
if (clone.constructor.name === 'HTMLDocument' || clone.constructor.name === 'DocumentFragment') {
|
|
316
316
|
// handle document and iframe
|
|
317
|
-
clone.body
|
|
317
|
+
// We are checking if we have multiple stylesheets present for the same clone or clone.body then we add
|
|
318
|
+
// them in the same order in which we receive them.
|
|
319
|
+
const lastLink = clone.body.querySelector('link[data-percy-adopted-stylesheets-serialized]:last-of-type');
|
|
320
|
+
if (lastLink) {
|
|
321
|
+
lastLink.after(styleLink);
|
|
322
|
+
} else {
|
|
323
|
+
clone.body.prepend(styleLink);
|
|
324
|
+
}
|
|
318
325
|
} else if (clone.constructor.name === 'ShadowRoot') {
|
|
319
|
-
clone.
|
|
326
|
+
const lastLink = clone.querySelector('link[data-percy-adopted-stylesheets-serialized]:last-of-type');
|
|
327
|
+
if (lastLink) {
|
|
328
|
+
lastLink.after(styleLink);
|
|
329
|
+
} else {
|
|
330
|
+
clone.prepend(styleLink);
|
|
331
|
+
}
|
|
320
332
|
}
|
|
321
333
|
}
|
|
322
334
|
} else {
|
|
@@ -491,7 +503,8 @@
|
|
|
491
503
|
dom,
|
|
492
504
|
disableShadowDOM,
|
|
493
505
|
resources,
|
|
494
|
-
cache
|
|
506
|
+
cache,
|
|
507
|
+
enableJavaScript
|
|
495
508
|
} = ctx;
|
|
496
509
|
// clones shadow DOM and light DOM for a given node
|
|
497
510
|
let cloneNode = (node, parent) => {
|
|
@@ -509,6 +522,43 @@
|
|
|
509
522
|
markElement(node, disableShadowDOM);
|
|
510
523
|
let clone = node.cloneNode();
|
|
511
524
|
|
|
525
|
+
// // Handle <style> tag specifically for media queries
|
|
526
|
+
// if (node.nodeName === 'STYLE' && !enableJavaScript) {
|
|
527
|
+
// if (node.textContent && node.textContent.trim() !== '') {
|
|
528
|
+
// clone.textContent = node.textContent;
|
|
529
|
+
// clone.setAttribute('data-percy-cssom-serialized', 'true');
|
|
530
|
+
// } else if (node.sheet && node.sheet.cssRules) {
|
|
531
|
+
// try {
|
|
532
|
+
// const cssText = Array.from(node.sheet.cssRules)
|
|
533
|
+
// .map(rule => rule.cssText)
|
|
534
|
+
// .join('\n');
|
|
535
|
+
// clone.textContent = cssText;
|
|
536
|
+
// clone.setAttribute('data-percy-cssom-serialized', 'true');
|
|
537
|
+
// } catch (err) {
|
|
538
|
+
// // ignore errors
|
|
539
|
+
// }
|
|
540
|
+
// }
|
|
541
|
+
// }
|
|
542
|
+
|
|
543
|
+
// Handle <style> tag specifically for media queries
|
|
544
|
+
if (node.nodeName === 'STYLE' && !enableJavaScript) {
|
|
545
|
+
var _node$textContent;
|
|
546
|
+
let cssText = ((_node$textContent = node.textContent) === null || _node$textContent === void 0 ? void 0 : _node$textContent.trim()) || '';
|
|
547
|
+
|
|
548
|
+
// istanbul ignore if
|
|
549
|
+
if (!cssText && node.sheet) {
|
|
550
|
+
try {
|
|
551
|
+
cssText = Array.from(node.sheet.cssRules || []).map(rule => rule.cssText).join('\n');
|
|
552
|
+
} catch (_) {
|
|
553
|
+
// ignore errors
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
if (cssText) {
|
|
557
|
+
clone.textContent = cssText;
|
|
558
|
+
clone.setAttribute('data-percy-cssom-serialized', 'true');
|
|
559
|
+
}
|
|
560
|
+
}
|
|
561
|
+
|
|
512
562
|
// We apply any element transformations here to avoid another treeWalk
|
|
513
563
|
applyElementTransformations(clone);
|
|
514
564
|
serializeBase64(clone, resources, cache);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/dom",
|
|
3
|
-
"version": "1.30.
|
|
3
|
+
"version": "1.30.9-alpha.0",
|
|
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": "alpha"
|
|
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": "16a3166eccd4b7e20606494e9f19f18ec9e4dd67"
|
|
39
39
|
}
|