mirror of
https://github.com/bigskysoftware/htmx.git
synced 2026-04-22 19:17:23 +00:00
Support event names with "." character (#1453)
hx-on throws an error when used with event names that contain dots
This commit is contained in:
@@ -1972,7 +1972,7 @@ return (function () {
|
||||
var curlyCount = 0;
|
||||
while (lines.length > 0) {
|
||||
var line = lines.shift();
|
||||
var match = line.match(/^\s*([a-zA-Z:\-]+:)(.*)/);
|
||||
var match = line.match(/^\s*([a-zA-Z:\-\.]+:)(.*)/);
|
||||
if (curlyCount === 0 && match) {
|
||||
line.split(":")
|
||||
currentEvent = match[1].slice(0, -1); // strip last colon
|
||||
|
||||
@@ -136,4 +136,12 @@ describe("hx-on attribute", function() {
|
||||
}
|
||||
calledEvent.should.equal(true);
|
||||
});
|
||||
|
||||
it("can handle event types with dots", function () {
|
||||
var btn = make("<button hx-on='my.custom.event: window.foo = true'>Foo</button>");
|
||||
btn.dispatchEvent(new CustomEvent('my.custom.event'));
|
||||
window.foo.should.equal(true);
|
||||
delete window.foo;
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user