Skip to content

Commit 0b5f92f

Browse files
committed
maint(core utils): utils.hideOrShow: add updated dom to pat-update event data.
1 parent 7a03ef8 commit 0b5f92f

File tree

2 files changed

+31
-21
lines changed

2 files changed

+31
-21
lines changed

src/core/utils.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,8 @@ const hideOrShow = (nodes, visible, options, pattern_name) => {
272272
el.classList.add(visible ? "visible" : "hidden");
273273
$(el).trigger("pat-update", {
274274
pattern: pattern_name,
275+
action: "attribute-changed",
276+
dom: el,
275277
transition: "complete",
276278
});
277279
};
@@ -286,6 +288,8 @@ const hideOrShow = (nodes, visible, options, pattern_name) => {
286288
el.classList.add("in-progress");
287289
$(el).trigger("pat-update", {
288290
pattern: pattern_name,
291+
action: "attribute-changed",
292+
dom: el,
289293
transition: "start",
290294
});
291295
$(el)[visible ? t.show : t.hide]({

src/core/utils.test.js

Lines changed: 27 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -277,27 +277,6 @@ describe("hideOrShow", function () {
277277
expect(Array.prototype.slice.call($el[0].classList)).toEqual(["visible"]);
278278
});
279279

280-
it("Single pat-update event without a transition", function () {
281-
$("#lab").append('<div style="display: none"/>');
282-
var $el = $("#lab div");
283-
jest.spyOn($.fn, "trigger");
284-
utils.hideOrShow(
285-
$el,
286-
true,
287-
{
288-
transition: "none",
289-
effect: { duration: "fast", easing: "swing" },
290-
},
291-
"depends"
292-
);
293-
expect($.fn.trigger.mock.calls.length).toEqual(1);
294-
expect($.fn.trigger).toHaveBeenCalledWith("pat-update", {
295-
pattern: "depends",
296-
transition: "complete",
297-
});
298-
$.fn.trigger.mockRestore();
299-
});
300-
301280
it("Fadeout with 0 duration", function () {
302281
$("#lab").append("<div/>");
303282
var $el = $("#lab div");
@@ -321,6 +300,29 @@ describe("hideOrShow", function () {
321300
expect(Array.prototype.slice.call($el[0].classList)).toEqual(["hidden"]);
322301
});
323302

303+
it("Single pat-update event without a transition", function () {
304+
$("#lab").append('<div style="display: none"/>');
305+
var $el = $("#lab div");
306+
jest.spyOn($.fn, "trigger");
307+
utils.hideOrShow(
308+
$el,
309+
true,
310+
{
311+
transition: "none",
312+
effect: { duration: "fast", easing: "swing" },
313+
},
314+
"depends"
315+
);
316+
expect($.fn.trigger.mock.calls.length).toEqual(1);
317+
expect($.fn.trigger).toHaveBeenCalledWith("pat-update", {
318+
pattern: "depends",
319+
action: "attribute-changed",
320+
dom: $el[0],
321+
transition: "complete",
322+
});
323+
$.fn.trigger.mockRestore();
324+
});
325+
324326
it("pat-update event with a transition", async function () {
325327
$("#lab").append("<div/>");
326328
var $el = $("#lab div");
@@ -338,10 +340,14 @@ describe("hideOrShow", function () {
338340
expect($.fn.trigger.mock.calls.length).toEqual(2);
339341
expect($.fn.trigger).toHaveBeenCalledWith("pat-update", {
340342
pattern: "depends",
343+
action: "attribute-changed",
344+
dom: $el[0],
341345
transition: "start",
342346
});
343347
expect($.fn.trigger).toHaveBeenCalledWith("pat-update", {
344348
pattern: "depends",
349+
action: "attribute-changed",
350+
dom: $el[0],
345351
transition: "complete",
346352
});
347353
$.fn.trigger.mockRestore();

0 commit comments

Comments
 (0)