@schukai/monster 5.2.4 → 5.2.5

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/CHANGELOG.md CHANGED
@@ -2,6 +2,15 @@
2
2
 
3
3
 
4
4
 
5
+ ## [5.2.5] - 2026-11-17
6
+
7
+ ### Bug Fixes
8
+
9
+ - **floating:** ignore boxless clipping ancestors ([#610](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/610))
10
+ - **panel:** ignore unpainted outline widths in height calculations ([#611](https://gitlab.schukai.com/oss/libraries/javascript/monster/issues/611))
11
+
12
+
13
+
5
14
  ## [5.2.4] - 2026-11-16
6
15
 
7
16
  ### Bug Fixes
package/package.json CHANGED
@@ -1 +1 @@
1
- {"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.6"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","exports":{".":"./source/monster.mjs","./CHANGELOG.md":"./CHANGELOG.md","./LICENSE":"./LICENSE","./README.md":"./README.md","./documentation/migrations/monster-5-options.md":"./documentation/migrations/monster-5-options.md","./package.json":"./package.json","./source/*":"./source/*","./test/*":"./test/*"},"files":["source","test/cases","test/util","documentation/migrations/monster-5-options.md","CHANGELOG.md"],"homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"sideEffects":["./source/monster.mjs","./source/components/**","./source/i18n/**","./test/**"],"type":"module","version":"5.2.4"}
1
+ {"author":"Volker Schukai","dependencies":{"@floating-ui/dom":"^1.7.6"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","exports":{".":"./source/monster.mjs","./CHANGELOG.md":"./CHANGELOG.md","./LICENSE":"./LICENSE","./README.md":"./README.md","./documentation/migrations/monster-5-options.md":"./documentation/migrations/monster-5-options.md","./package.json":"./package.json","./source/*":"./source/*","./test/*":"./test/*"},"files":["source","test/cases","test/util","documentation/migrations/monster-5-options.md","CHANGELOG.md"],"homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"sideEffects":["./source/monster.mjs","./source/components/**","./source/i18n/**","./test/**"],"type":"module","version":"5.2.5"}
@@ -1267,7 +1267,10 @@ function isPopperContentWrapper(element) {
1267
1267
  }
1268
1268
 
1269
1269
  function isClippingContainer(style) {
1270
- if (!style) {
1270
+ // display: contents generates no box, so its overflow cannot clip descendants.
1271
+ // Keep this decision shared by boundary resolution and visibility checks;
1272
+ // a zero-sized element that does generate a box must still clip normally.
1273
+ if (!style || style.display === "contents") {
1271
1274
  return false;
1272
1275
  }
1273
1276
 
@@ -229,7 +229,9 @@ function calculateMaximumHeight(element) {
229
229
  const marginBottom = parseFloat(style.marginBottom);
230
230
 
231
231
  // Outline and box-shadow
232
- const outlineHeight = parseFloat(style.outlineWidth);
232
+ // Some browsers resolve a nonzero width even when no outline is painted.
233
+ const outlineHeight =
234
+ style.outlineStyle === "none" ? 0 : parseFloat(style.outlineWidth);
233
235
  // This is a simplification; box-shadow is more complex to parse
234
236
  const boxShadowVertical = parseFloat(style.boxShadow.split(" ")[3] || 0);
235
237
 
@@ -156,7 +156,7 @@ function getMonsterVersion() {
156
156
  }
157
157
 
158
158
  /** Managed by the release script; keep synchronized with package.json. */
159
- monsterVersion = new Version("5.2.4");
159
+ monsterVersion = new Version("5.2.5");
160
160
 
161
161
  return monsterVersion;
162
162
  }
@@ -4,6 +4,7 @@ import { initJSDOM } from "../../../util/jsdom.mjs";
4
4
  let expect = chai.expect;
5
5
 
6
6
  let resolveClippingBoundaryElement;
7
+ let resolveParentPopperContentBoundary;
7
8
  let applyAdaptiveFloatingElementSize;
8
9
  let applyFloatingReferenceVisibility;
9
10
  let createVisibilityRecoveryConfig;
@@ -21,6 +22,8 @@ describe("form floating-ui boundary resolution", function () {
21
22
  })
22
23
  .then((m) => {
23
24
  resolveClippingBoundaryElement = m.resolveClippingBoundaryElement;
25
+ resolveParentPopperContentBoundary =
26
+ m.resolveParentPopperContentBoundary;
24
27
  applyAdaptiveFloatingElementSize = m.applyAdaptiveFloatingElementSize;
25
28
  applyFloatingReferenceVisibility = m.applyFloatingReferenceVisibility;
26
29
  createVisibilityRecoveryConfig = m.createVisibilityRecoveryConfig;
@@ -77,6 +80,209 @@ describe("form floating-ui boundary resolution", function () {
77
80
  expect(resolveClippingBoundaryElement(control, popper)).to.equal(wrapper);
78
81
  });
79
82
 
83
+ describe("boxless clipping ancestors (#610)", function () {
84
+ const rect = (left, top, width, height) => ({
85
+ x: left,
86
+ y: top,
87
+ left,
88
+ top,
89
+ width,
90
+ height,
91
+ right: left + width,
92
+ bottom: top + height,
93
+ });
94
+ const mount = () => {
95
+ const wrapper = document.createElement("div");
96
+ const reference = document.createElement("div");
97
+ const popper = document.createElement("div");
98
+ wrapper.getBoundingClientRect = () => rect(0, 0, 0, 0);
99
+ reference.getBoundingClientRect = () => rect(100, 100, 100, 40);
100
+ popper.getBoundingClientRect = () => rect(100, 140, 200, 100);
101
+ wrapper.append(reference, popper);
102
+ document.getElementById("mocks").append(wrapper);
103
+ return { wrapper, reference, popper };
104
+ };
105
+
106
+ for (const [property, value] of [
107
+ ["overflow", "hidden"],
108
+ ["overflow", "auto"],
109
+ ["overflow", "scroll"],
110
+ ["overflow", "clip"],
111
+ ["overflowX", "hidden"],
112
+ ["overflowY", "auto"],
113
+ ]) {
114
+ it(`ignores display: contents with ${property}: ${value} for boundaries and visibility`, function () {
115
+ const { wrapper, reference, popper } = mount();
116
+ wrapper.style.display = "contents";
117
+ wrapper.style[property] = value;
118
+
119
+ expect(resolveClippingBoundaryElement(reference, popper)).to.equal(
120
+ null,
121
+ );
122
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
123
+ true,
124
+ );
125
+ expect(getFloatingVisibleRatio(popper)).to.equal(1);
126
+ });
127
+
128
+ it(`preserves a genuinely zero-sized box with ${property}: ${value}`, function () {
129
+ const { wrapper, reference, popper } = mount();
130
+ wrapper.style.display = "block";
131
+ wrapper.style[property] = value;
132
+
133
+ expect(resolveClippingBoundaryElement(reference, popper)).to.equal(
134
+ wrapper,
135
+ );
136
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
137
+ false,
138
+ );
139
+ expect(popper.dataset.monsterReferenceHidden).to.equal("true");
140
+ expect(getFloatingVisibleRatio(popper)).to.equal(0);
141
+ });
142
+ }
143
+
144
+ it("continues through nested contents wrappers to a real clipping ancestor", function () {
145
+ const { wrapper, reference, popper } = mount();
146
+ wrapper.style.cssText = "display: contents; overflow: hidden";
147
+ const inner = document.createElement("div");
148
+ inner.style.cssText = "display: contents; overflow: auto";
149
+ inner.append(reference, popper);
150
+ wrapper.append(inner);
151
+ const outer = document.createElement("div");
152
+ outer.style.overflow = "hidden";
153
+ outer.getBoundingClientRect = () => rect(50, 50, 150, 150);
154
+ wrapper.replaceWith(outer);
155
+ outer.append(wrapper);
156
+
157
+ expect(resolveClippingBoundaryElement(reference, popper)).to.equal(outer);
158
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
159
+ true,
160
+ );
161
+ expect(getFloatingVisibleRatio(popper)).to.equal(0.3);
162
+
163
+ // A partially visible reference remains usable; a fully clipped one hides.
164
+ reference.getBoundingClientRect = () => rect(180, 100, 100, 40);
165
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
166
+ true,
167
+ );
168
+ reference.getBoundingClientRect = () => rect(200, 100, 100, 40);
169
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
170
+ false,
171
+ );
172
+ });
173
+
174
+ it("does not skip a real inner clipping box below a contents ancestor", function () {
175
+ const { wrapper, reference, popper } = mount();
176
+ wrapper.style.cssText = "display: contents; overflow: hidden";
177
+ const inner = document.createElement("div");
178
+ inner.style.overflow = "auto";
179
+ inner.getBoundingClientRect = () => rect(50, 50, 150, 150);
180
+ inner.append(reference, popper);
181
+ wrapper.append(inner);
182
+
183
+ expect(resolveClippingBoundaryElement(reference, popper)).to.equal(inner);
184
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
185
+ true,
186
+ );
187
+ expect(getFloatingVisibleRatio(popper)).to.equal(0.3);
188
+ });
189
+
190
+ for (const composedAncestor of ["shadow host", "slot"]) {
191
+ it(`traverses a boxless ${composedAncestor} while preserving its real outer boundary`, function () {
192
+ const { wrapper, reference, popper } = mount();
193
+ wrapper.style.overflow = "hidden";
194
+ wrapper.getBoundingClientRect = () => rect(50, 50, 150, 150);
195
+ const host = document.createElement("div");
196
+ const shadow = host.attachShadow({ mode: "open" });
197
+ wrapper.append(host);
198
+ if (composedAncestor === "shadow host") {
199
+ host.style.cssText = "display: contents; overflow: hidden";
200
+ shadow.append(reference, popper);
201
+ } else {
202
+ const slot = document.createElement("slot");
203
+ slot.style.cssText = "display: contents; overflow: hidden";
204
+ shadow.append(slot);
205
+ host.append(reference, popper);
206
+ expect(reference.assignedSlot).to.equal(slot);
207
+ }
208
+
209
+ expect(resolveClippingBoundaryElement(reference, popper)).to.equal(
210
+ wrapper,
211
+ );
212
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
213
+ true,
214
+ );
215
+ expect(getFloatingVisibleRatio(popper)).to.equal(0.3);
216
+ });
217
+ }
218
+
219
+ it("reevaluates contents/block changes and restores reference visibility", function () {
220
+ const { wrapper, reference, popper } = mount();
221
+ wrapper.style.cssText = "display: contents; overflow: hidden";
222
+ for (const display of ["contents", "block", "contents"]) {
223
+ wrapper.style.display = display;
224
+ const hasBox = display === "block";
225
+ expect(resolveClippingBoundaryElement(reference, popper)).to.equal(
226
+ hasBox ? wrapper : null,
227
+ );
228
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
229
+ !hasBox,
230
+ );
231
+ expect(getFloatingVisibleRatio(popper)).to.equal(hasBox ? 0 : 1);
232
+ expect(popper.style.visibility).to.equal(hasBox ? "hidden" : "");
233
+ expect(popper.dataset.monsterReferenceHidden).to.equal(
234
+ hasBox ? "true" : undefined,
235
+ );
236
+ }
237
+ expect(wrapper.style.overflow).to.equal("hidden");
238
+ });
239
+
240
+ it("preserves nested popup boundary escape without losing real content clipping", function () {
241
+ const { wrapper, reference, popper } = mount();
242
+ wrapper.style.cssText = "display: contents; overflow: hidden";
243
+ const outer = document.createElement("div");
244
+ outer.style.overflow = "hidden";
245
+ outer.getBoundingClientRect = () => rect(0, 0, 500, 500);
246
+ const parentPopper = document.createElement("div");
247
+ parentPopper.dataset.monsterRole = "popper";
248
+ const content = document.createElement("div");
249
+ content.setAttribute("part", "content");
250
+ content.dataset.monsterOverflowMode = "both";
251
+ content.style.overflow = "auto";
252
+ content.getBoundingClientRect = () => rect(50, 50, 150, 150);
253
+ wrapper.replaceWith(outer);
254
+ outer.append(parentPopper);
255
+ parentPopper.append(content);
256
+ content.append(wrapper);
257
+
258
+ expect(resolveClippingBoundaryElement(reference, popper)).to.equal(outer);
259
+ expect(resolveParentPopperContentBoundary(reference, popper)).to.equal(
260
+ content,
261
+ );
262
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
263
+ true,
264
+ );
265
+ expect(getFloatingVisibleRatio(popper)).to.equal(0.3);
266
+ reference.getBoundingClientRect = () => rect(220, 100, 100, 40);
267
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
268
+ false,
269
+ );
270
+ });
271
+
272
+ it("still clips against the viewport above a contents wrapper", function () {
273
+ const { wrapper, reference, popper } = mount();
274
+ wrapper.style.cssText = "display: contents; overflow: hidden";
275
+ reference.getBoundingClientRect = () => rect(100, -40, 100, 40);
276
+ popper.getBoundingClientRect = () => rect(100, -50, 200, 100);
277
+
278
+ expect(resolveClippingBoundaryElement(reference, popper)).to.equal(null);
279
+ expect(applyFloatingReferenceVisibility(reference, popper)).to.equal(
280
+ false,
281
+ );
282
+ expect(getFloatingVisibleRatio(popper)).to.equal(0.5);
283
+ });
284
+ });
285
+
80
286
  it("should adapt the content max height to the available popper height", function () {
81
287
  const mocks = document.getElementById("mocks");
82
288
  const popper = document.createElement("div");
@@ -42,9 +42,26 @@ describe("SplitScreen", () => {
42
42
  });
43
43
 
44
44
  describe("document.createElement()", () => {
45
+ let originalInnerHeight;
46
+ let originalMocksStyle;
47
+ beforeEach(() => {
48
+ originalInnerHeight = Object.getOwnPropertyDescriptor(
49
+ window,
50
+ "innerHeight",
51
+ );
52
+ originalMocksStyle = document
53
+ .getElementById("mocks")
54
+ .getAttribute("style");
55
+ });
56
+
45
57
  afterEach(() => {
46
58
  const mocks = document.getElementById("mocks");
47
59
  mocks.innerHTML = "";
60
+ if (originalMocksStyle === null) mocks.removeAttribute("style");
61
+ else mocks.setAttribute("style", originalMocksStyle);
62
+ if (originalInnerHeight)
63
+ Object.defineProperty(window, "innerHeight", originalInnerHeight);
64
+ else delete window.innerHeight;
48
65
  });
49
66
 
50
67
  it("should have buttons and SplitScreen", (done) => {
@@ -93,5 +110,73 @@ describe("SplitScreen", () => {
93
110
  }
94
111
  }, 0);
95
112
  });
113
+
114
+ describe("outline height allowances (#611)", () => {
115
+ const mount = ({ panelOutline, parentOutline, parentHeight = 1000 }) => {
116
+ const parent = document.createElement("div");
117
+ parent.style.cssText = `height: ${parentHeight}px; outline: ${parentOutline}`;
118
+ // JSDOM has no layout; control the parent limit independently of CSS measurement.
119
+ Object.defineProperty(parent, "clientHeight", {
120
+ configurable: true,
121
+ value: parentHeight,
122
+ });
123
+ const panel = document.createElement("monster-panel");
124
+ // Set longhands explicitly: JSDOM does not expand the outline shorthand.
125
+ for (const [element, outline] of [
126
+ [panel, panelOutline],
127
+ [parent, parentOutline],
128
+ ]) {
129
+ const [width, style] = outline.split(" ");
130
+ element.style.outlineWidth = width;
131
+ element.style.outlineStyle = style;
132
+ }
133
+ parent.append(panel);
134
+ document.getElementById("mocks").append(parent);
135
+ panel.setOption("heightAdjustment", 8);
136
+ panel.getBoundingClientRect = () => ({ top: 120 });
137
+ Object.defineProperty(window, "innerHeight", {
138
+ configurable: true,
139
+ value: 720,
140
+ });
141
+ return { panel, parent };
142
+ };
143
+
144
+ for (const [panelOutline, parentOutline, expected] of [
145
+ ["3px none", "4px none", 608],
146
+ ["3px solid", "4px none", 605],
147
+ ["3px none", "4px dashed", 604],
148
+ ["3px solid", "4px dashed", 601],
149
+ ]) {
150
+ it(`allows only painted outlines (panel: ${panelOutline}, parent: ${parentOutline})`, () => {
151
+ const { panel } = mount({ panelOutline, parentOutline });
152
+ expect(panel.getMaximumHeight()).to.equal(expected);
153
+ expect(panel.recalculateHeight()).to.equal(panel);
154
+ expect(panel.style.height).to.equal(`${expected}px`);
155
+ });
156
+ }
157
+
158
+ it("still clamps to a smaller parent when outlines are not painted", () => {
159
+ const { panel } = mount({
160
+ panelOutline: "3px none",
161
+ parentOutline: "4px none",
162
+ parentHeight: 300,
163
+ });
164
+ expect(panel.getMaximumHeight()).to.equal(300);
165
+ panel.recalculateHeight();
166
+ expect(panel.style.height).to.equal("300px");
167
+ });
168
+
169
+ it("still reserves real parent borders, padding and margins", () => {
170
+ const { panel, parent } = mount({
171
+ panelOutline: "3px none",
172
+ parentOutline: "4px none",
173
+ });
174
+ parent.style.boxSizing = "content-box";
175
+ parent.style.borderBottom = "2px solid";
176
+ parent.style.paddingBottom = "6px";
177
+ parent.style.marginBottom = "4px";
178
+ expect(panel.getMaximumHeight()).to.equal(596);
179
+ });
180
+ });
96
181
  });
97
182
  });