Skip to content

Commit 8606200

Browse files
committed
alternative to key is fir-key to avoid conflict with alpinejs key usage
1 parent 4b7a922 commit 8606200

File tree

2 files changed

+10
-2
lines changed

2 files changed

+10
-2
lines changed

alpinejs-plugin/src/index.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,9 @@ const Plugin = (Alpine) => {
182182
event_id: id,
183183
params: params,
184184
target: target,
185-
element_key: el.getAttribute('key'),
185+
element_key:
186+
el.getAttribute('key') ||
187+
el.getAttribute('fir-key'),
186188
session_id: getSessionIDFromCookie(),
187189
})
188190
}
@@ -307,7 +309,9 @@ const Plugin = (Alpine) => {
307309
params: params,
308310
is_form: true,
309311
target: target,
310-
element_key: el.getAttribute('key'),
312+
element_key:
313+
el.getAttribute('key') ||
314+
el.getAttribute('fir-key'),
311315
session_id: getSessionIDFromCookie(),
312316
})
313317

writeattr.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ func writeAttributes(node *html.Node) {
155155

156156
// fir-myevent-ok--myblock
157157
key := getAttr(node, "key")
158+
firKey := getAttr(node, "fir-key")
159+
if len(firKey) != 0 {
160+
key = firKey
161+
}
158162
targetClass := fmt.Sprintf("fir-%s", getClassNameWithKey(eventns, &key))
159163
classes := strings.Fields(getAttr(node, "class"))
160164
if !slices.Contains(classes, targetClass) {

0 commit comments

Comments
 (0)