@percy/dom 1.31.10 → 1.31.11-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.
- package/dist/bundle.js +37 -5
- package/package.json +3 -3
package/dist/bundle.js
CHANGED
|
@@ -507,8 +507,21 @@
|
|
|
507
507
|
|
|
508
508
|
/* global XPathResult */
|
|
509
509
|
const PSEDUO_ELEMENT_MARKER_ATTR = 'data-percy-pseudo-element-id';
|
|
510
|
-
|
|
511
|
-
|
|
510
|
+
const POPOVER_OPEN_ATTR = 'data-percy-popover-open';
|
|
511
|
+
function isPopoverOpen(ctx, element) {
|
|
512
|
+
try {
|
|
513
|
+
return element.matches(':popover-open');
|
|
514
|
+
} catch (err) {
|
|
515
|
+
ctx.warnings.add('Browser does not support :popover-open pseudo-class.');
|
|
516
|
+
return false;
|
|
517
|
+
}
|
|
518
|
+
}
|
|
519
|
+
function markElementIfNeeded(ctx, element, markWithId) {
|
|
520
|
+
if (!markWithId) return;
|
|
521
|
+
if (element.hasAttribute('popover') && isPopoverOpen(ctx, element) && !element.hasAttribute(POPOVER_OPEN_ATTR)) {
|
|
522
|
+
element.setAttribute(POPOVER_OPEN_ATTR, 'true');
|
|
523
|
+
}
|
|
524
|
+
if (!element.getAttribute(PSEDUO_ELEMENT_MARKER_ATTR)) {
|
|
512
525
|
element.setAttribute(PSEDUO_ELEMENT_MARKER_ATTR, uid());
|
|
513
526
|
}
|
|
514
527
|
}
|
|
@@ -532,7 +545,7 @@
|
|
|
532
545
|
ctx.warnings.add(`No element found with ID: ${id} for pseudo-class serialization`);
|
|
533
546
|
continue;
|
|
534
547
|
}
|
|
535
|
-
markElementIfNeeded(element, markWithId);
|
|
548
|
+
markElementIfNeeded(ctx, element, markWithId);
|
|
536
549
|
elements.push(element);
|
|
537
550
|
}
|
|
538
551
|
}
|
|
@@ -546,7 +559,7 @@
|
|
|
546
559
|
continue;
|
|
547
560
|
}
|
|
548
561
|
const element = elementCollection[0];
|
|
549
|
-
markElementIfNeeded(element, markWithId);
|
|
562
|
+
markElementIfNeeded(ctx, element, markWithId);
|
|
550
563
|
elements.push(element);
|
|
551
564
|
}
|
|
552
565
|
}
|
|
@@ -558,12 +571,31 @@
|
|
|
558
571
|
ctx.warnings.add(`No element found for XPath: ${xpathExpression} for pseudo-class serialization`);
|
|
559
572
|
continue;
|
|
560
573
|
}
|
|
561
|
-
markElementIfNeeded(element, markWithId);
|
|
574
|
+
markElementIfNeeded(ctx, element, markWithId);
|
|
562
575
|
} catch (err) {
|
|
576
|
+
ctx.warnings.add(`Invalid XPath expression "${xpathExpression}" for pseudo-class serialization. Error: ${err.message}`);
|
|
563
577
|
console.warn(`Invalid XPath expression "${xpathExpression}". Error: ${err.message}`);
|
|
564
578
|
}
|
|
565
579
|
}
|
|
566
580
|
}
|
|
581
|
+
if (config.selector && Array.isArray(config.selector)) {
|
|
582
|
+
for (const selector of config.selector) {
|
|
583
|
+
try {
|
|
584
|
+
const matched = Array.from(dom.querySelectorAll(selector));
|
|
585
|
+
if (!matched.length) {
|
|
586
|
+
ctx.warnings.add(`No element found for selector: ${selector} for pseudo-class serialization`);
|
|
587
|
+
continue;
|
|
588
|
+
}
|
|
589
|
+
matched.forEach(el => {
|
|
590
|
+
markElementIfNeeded(ctx, el, markWithId);
|
|
591
|
+
elements.push(el);
|
|
592
|
+
});
|
|
593
|
+
} catch (err) {
|
|
594
|
+
ctx.warnings.add(`Invalid selector "${selector}" for pseudo-class serialization. Error: ${err.message}`);
|
|
595
|
+
console.warn(`Invalid selector "${selector}". Error: ${err.message}`);
|
|
596
|
+
}
|
|
597
|
+
}
|
|
598
|
+
}
|
|
567
599
|
return elements;
|
|
568
600
|
}
|
|
569
601
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@percy/dom",
|
|
3
|
-
"version": "1.31.
|
|
3
|
+
"version": "1.31.11-beta.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": "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": "
|
|
38
|
+
"gitHead": "eda81f78ff9e58dac7c1c64e5f92001e5cbf3368"
|
|
39
39
|
}
|