@jsenv/dom 0.8.5 → 0.8.6
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/jsenv_dom.js +20 -6
- package/package.json +1 -1
package/dist/jsenv_dom.js
CHANGED
|
@@ -92,16 +92,17 @@ const getElementSignature = (element) => {
|
|
|
92
92
|
}
|
|
93
93
|
return `[${functionLabel}]`;
|
|
94
94
|
}
|
|
95
|
-
if (element.nodeType === Node.TEXT_NODE) {
|
|
96
|
-
return `#text(${getElementSignature(element.nodeValue)})`;
|
|
97
|
-
}
|
|
98
95
|
if (element.props) {
|
|
99
96
|
const type = element.type;
|
|
97
|
+
const elementName = typeof type === "function" ? type.name : type;
|
|
100
98
|
const id = element.props.id;
|
|
101
99
|
if (id) {
|
|
102
|
-
return `<${
|
|
100
|
+
return `<${elementName} id="${id}" />`;
|
|
103
101
|
}
|
|
104
|
-
return `<${
|
|
102
|
+
return `<${elementName} />`;
|
|
103
|
+
}
|
|
104
|
+
if (element.nodeType === Node.TEXT_NODE) {
|
|
105
|
+
return `#text(${getElementSignature(element.nodeValue)})`;
|
|
105
106
|
}
|
|
106
107
|
|
|
107
108
|
const tagName = element.tagName.toLowerCase();
|
|
@@ -399,6 +400,14 @@ const parseCSSColor = (color, element) => {
|
|
|
399
400
|
if (typeof color !== "string") {
|
|
400
401
|
return color;
|
|
401
402
|
}
|
|
403
|
+
if (color === "inherit") {
|
|
404
|
+
if (!element) {
|
|
405
|
+
return color;
|
|
406
|
+
}
|
|
407
|
+
const computedStyle = getComputedStyle(element);
|
|
408
|
+
const resolvedColor = parseCSSColor(computedStyle.color, element);
|
|
409
|
+
return resolvedColor;
|
|
410
|
+
}
|
|
402
411
|
let resolvedColor = color;
|
|
403
412
|
|
|
404
413
|
// Handle light-dark() function
|
|
@@ -9372,6 +9381,7 @@ const pickPositionRelativeTo = (
|
|
|
9372
9381
|
{
|
|
9373
9382
|
alignToViewportEdgeWhenTargetNearEdge = 0,
|
|
9374
9383
|
minLeft = 0,
|
|
9384
|
+
positionPreference,
|
|
9375
9385
|
forcePosition,
|
|
9376
9386
|
} = {},
|
|
9377
9387
|
) => {
|
|
@@ -9452,8 +9462,12 @@ const pickPositionRelativeTo = (
|
|
|
9452
9462
|
position = forcePosition;
|
|
9453
9463
|
break determine_position;
|
|
9454
9464
|
}
|
|
9455
|
-
const
|
|
9465
|
+
const elementPreferredPosition = element.getAttribute("data-position");
|
|
9456
9466
|
const minContentVisibilityRatio = 0.6; // 60% minimum visibility to keep position
|
|
9467
|
+
|
|
9468
|
+
// Check positionPreference parameter first, then element attribute
|
|
9469
|
+
const preferredPosition = positionPreference || elementPreferredPosition;
|
|
9470
|
+
|
|
9457
9471
|
if (preferredPosition) {
|
|
9458
9472
|
// Element has a preferred position - try to keep it unless we really struggle
|
|
9459
9473
|
const visibleRatio =
|