Skip to content

Commit 7434236

Browse files
committed
maint(pat-switch): Add updated dom to pat-update event data.
1 parent 41f8bb3 commit 7434236

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/pat/switch/switch.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,11 @@ export default Base.extend({
9898
target.classList.add(add);
9999
}
100100

101-
$(target).trigger("pat-update", { pattern: "switch" });
101+
$(target).trigger("pat-update", {
102+
pattern: "switch",
103+
action: "attribute-changed",
104+
dom: target,
105+
});
102106
}
103107
},
104108
});

src/pat/switch/switch.test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,14 +116,15 @@ describe("pat-switch", function () {
116116

117117
it("Send pat-update event", function () {
118118
document.body.innerHTML = "<div></div>";
119+
const target = document.querySelector("body div");
119120
const instance = new pattern(document.createElement("div"));
120121
const spy_trigger = jest.spyOn($.fn, "trigger");
121122
instance._update("body div", null, "icon-alert");
122-
expect(
123-
document.querySelector("body div").classList.contains("icon-alert")
124-
).toBe(true);
123+
expect(target.classList.contains("icon-alert")).toBe(true);
125124
expect(spy_trigger).toHaveBeenCalledWith("pat-update", {
126125
pattern: "switch",
126+
action: "attribute-changed",
127+
dom: target,
127128
});
128129
});
129130
});

0 commit comments

Comments
 (0)