Skip to content

Commit 5ed69cc

Browse files
authored
Merge pull request #97 from hydrostack/use-dataset-for-custom-attributes
Use dataset for custom attributes
2 parents 02837d2 + a8ef452 commit 5ed69cc

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

src/Scripts/hydro.js

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,7 @@
217217
formData.set(propertyName, el.value);
218218
}
219219

220-
el.setAttribute("hydro-operation-id", binding[component.id].operationId);
220+
el.setAttribute("data-operation-id", binding[component.id].operationId);
221221
el.classList.add('hydro-request');
222222

223223
if (bindAlreadyInitialized) {
@@ -261,7 +261,7 @@
261261
}
262262

263263
const operationId = generateGuid();
264-
el.setAttribute("hydro-operation-id", operationId);
264+
el.setAttribute("data-operation-id", operationId);
265265

266266
await hydroRequest(el, url, { parameters: action.parameters }, 'action', null, operationId, true);
267267
}
@@ -289,7 +289,7 @@
289289
if (!operationStatus[operationId]) {
290290
operationStatus[operationId] = 0;
291291

292-
const operationTrigger = document.querySelector(`[hydro-operation-id="${operationId}"]`);
292+
const operationTrigger = document.querySelector(`[data-operation-id="${operationId}"]`);
293293

294294
if (operationTrigger) {
295295
classTimeout = setTimeout(() => operationTrigger.classList.add('hydro-request'), 200);
@@ -402,16 +402,16 @@
402402
}
403403
}
404404

405-
if (from.getAttribute && from.getAttribute("hydro-operation-id")) {
405+
if (from.getAttribute && from.getAttribute("data-operation-id")) {
406406
// skip result from bind operation when this operating element is not a hydro component and is awaiting a request already
407-
if (type === 'bind' && operationId !== from.getAttribute("hydro-operation-id") && from.getAttribute("hydro") === null) {
407+
if (type === 'bind' && operationId !== from.getAttribute("data-operation-id") && from.getAttribute("hydro") === null) {
408408
skip();
409409
counter++;
410410
return;
411411
}
412412

413413
// set the operation id, disabled state and hydro class that would be lost after morph
414-
to.setAttribute("hydro-operation-id", from.getAttribute("hydro-operation-id"));
414+
to.setAttribute("data-operation-id", from.getAttribute("data-operation-id"));
415415
to.disabled = from.disabled;
416416
if (from.classList.contains('hydro-request')) {
417417
to.classList.add('hydro-request');
@@ -507,14 +507,14 @@
507507
clearTimeout(disableTimer);
508508

509509
if (operationId) {
510-
const operationTrigger = document.querySelectorAll(`[hydro-operation-id="${operationId}"]`);
510+
const operationTrigger = document.querySelectorAll(`[data-operation-id="${operationId}"]`);
511511
operationStatus[operationId]--;
512512

513513
if (operationTrigger.length && (operationStatus[operationId] <= 0)) {
514514
operationTrigger.forEach(trigger => {
515515
trigger.disabled = false;
516516
trigger.classList.remove('hydro-request');
517-
trigger.removeAttribute('hydro-operation-id');
517+
trigger.removeAttribute('data-operation-id');
518518
})
519519
}
520520
}
@@ -634,7 +634,7 @@ document.addEventListener('alpine:init', () => {
634634
event.preventDefault();
635635

636636
const operationId = window.Hydro.generateGuid();
637-
el.setAttribute("hydro-operation-id", operationId);
637+
el.setAttribute("data-operation-id", operationId);
638638

639639
const eventName = `${scope}:${trigger.name}`;
640640
const eventData = {

0 commit comments

Comments
 (0)