@percy/dom 1.30.9-beta.2 → 1.30.9-beta.4

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 -1
  2. package/package.json +2 -2
package/dist/bundle.js CHANGED
@@ -503,7 +503,8 @@
503
503
  dom,
504
504
  disableShadowDOM,
505
505
  resources,
506
- cache
506
+ cache,
507
+ enableJavaScript
507
508
  } = ctx;
508
509
  // clones shadow DOM and light DOM for a given node
509
510
  let cloneNode = (node, parent) => {
@@ -521,6 +522,26 @@
521
522
  markElement(node, disableShadowDOM);
522
523
  let clone = node.cloneNode();
523
524
 
525
+ // Handle <style> tag specifically for media queries
526
+ if (node.nodeName === 'STYLE' && !enableJavaScript) {
527
+ var _node$textContent;
528
+ let cssText = ((_node$textContent = node.textContent) === null || _node$textContent === void 0 ? void 0 : _node$textContent.trim()) || '';
529
+ if (!cssText && node.sheet) {
530
+ try {
531
+ const cssRules = node.sheet.cssRules;
532
+ if (cssRules && cssRules.length > 0) {
533
+ cssText = Array.from(cssRules).map(rule => rule.cssText).join('\n');
534
+ }
535
+ } catch (_) {
536
+ // ignore errors
537
+ }
538
+ }
539
+ if (cssText) {
540
+ clone.textContent = cssText;
541
+ clone.setAttribute('data-percy-cssom-serialized', 'true');
542
+ }
543
+ }
544
+
524
545
  // We apply any element transformations here to avoid another treeWalk
525
546
  applyElementTransformations(clone);
526
547
  serializeBase64(clone, resources, cache);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@percy/dom",
3
- "version": "1.30.9-beta.2",
3
+ "version": "1.30.9-beta.4",
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": "13493f9b47d1c7bc9e6f86a1499970012e4e169a"
38
+ "gitHead": "da775ecb34bc01824f0dee8f208201c373ca78d4"
39
39
  }