@skrillex1224/playwright-toolkit 2.1.229 → 2.1.230
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/index.cjs +28 -5
- package/dist/index.cjs.map +2 -2
- package/dist/index.js +28 -5
- package/dist/index.js.map +2 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -553,6 +553,21 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
553
553
|
const scrollableOverflow = /* @__PURE__ */ new Set(["auto", "scroll", "overlay"]);
|
|
554
554
|
return scrollableOverflow.has(overflowY) || scrollableOverflow.has(overflow);
|
|
555
555
|
};
|
|
556
|
+
const measureNeededHeight = (el) => {
|
|
557
|
+
if (!el) return 0;
|
|
558
|
+
const scrollHeight = Math.ceil(el.scrollHeight || 0);
|
|
559
|
+
if (scrollHeight <= 0) return 0;
|
|
560
|
+
if (isDocumentElement(el)) {
|
|
561
|
+
return scrollHeight;
|
|
562
|
+
}
|
|
563
|
+
const rect = el.getBoundingClientRect();
|
|
564
|
+
if (!rect || rect.width <= 0 || rect.height <= 0) {
|
|
565
|
+
return 0;
|
|
566
|
+
}
|
|
567
|
+
const documentTop = Math.max(0, Math.ceil(rect.top + (window.scrollY || window.pageYOffset || 0)));
|
|
568
|
+
return documentTop + scrollHeight;
|
|
569
|
+
};
|
|
570
|
+
const scrollableElements = [];
|
|
556
571
|
candidates.forEach((el) => {
|
|
557
572
|
const style = window.getComputedStyle(el);
|
|
558
573
|
const rect = el.getBoundingClientRect();
|
|
@@ -562,13 +577,14 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
562
577
|
if (!isScrollableY(el, style)) {
|
|
563
578
|
return;
|
|
564
579
|
}
|
|
565
|
-
const
|
|
566
|
-
if (
|
|
580
|
+
const neededHeight = measureNeededHeight(el);
|
|
581
|
+
if (neededHeight <= 0) {
|
|
567
582
|
return;
|
|
568
583
|
}
|
|
569
|
-
if (
|
|
570
|
-
maxHeight =
|
|
584
|
+
if (neededHeight > maxHeight) {
|
|
585
|
+
maxHeight = neededHeight;
|
|
571
586
|
}
|
|
587
|
+
scrollableElements.push(el);
|
|
572
588
|
if (isDocumentElement(el)) {
|
|
573
589
|
return;
|
|
574
590
|
}
|
|
@@ -584,6 +600,7 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
584
600
|
el.classList.add(className);
|
|
585
601
|
}
|
|
586
602
|
if (forceScrollableHeight) {
|
|
603
|
+
const scrollHeight = Math.ceil(el.scrollHeight || 0);
|
|
587
604
|
el.style.setProperty("overflow", "visible", "important");
|
|
588
605
|
el.style.setProperty("height", `${scrollHeight}px`, "important");
|
|
589
606
|
el.style.setProperty("min-height", `${scrollHeight}px`, "important");
|
|
@@ -594,10 +611,16 @@ var expandScrollableContent = async (page, options = {}) => {
|
|
|
594
611
|
el.style.height = "auto";
|
|
595
612
|
el.style.maxHeight = "none";
|
|
596
613
|
});
|
|
614
|
+
scrollableElements.forEach((el) => {
|
|
615
|
+
const neededHeight = measureNeededHeight(el);
|
|
616
|
+
if (neededHeight > maxHeight) {
|
|
617
|
+
maxHeight = neededHeight;
|
|
618
|
+
}
|
|
619
|
+
});
|
|
597
620
|
return maxHeight;
|
|
598
621
|
}, {
|
|
599
622
|
className: EXPANDED_SCROLLABLE_CLASS,
|
|
600
|
-
forceScrollableHeight:
|
|
623
|
+
forceScrollableHeight: options.forceScrollableHeight !== false,
|
|
601
624
|
visibleOnly: options.visibleOnly !== false
|
|
602
625
|
});
|
|
603
626
|
};
|