From e832c20a98e7c155f3f1b06263f515aad530b79a Mon Sep 17 00:00:00 2001 From: Taylor Vann Date: Wed, 10 Jun 2026 09:39:43 -0700 Subject: [PATCH] update superaction, builds --- examples/counter/bundled.js | 52 ++++++++++++++++++++----------------- examples/form/bundled.js | 52 ++++++++++++++++++++----------------- package-lock.json | 12 ++++----- package.json | 2 +- 4 files changed, 63 insertions(+), 55 deletions(-) diff --git a/examples/counter/bundled.js b/examples/counter/bundled.js index be4e26b..1e6cca2 100644 --- a/examples/counter/bundled.js +++ b/examples/counter/bundled.js @@ -30266,10 +30266,9 @@ class ActionEvent extends Event { class SuperAction { #connected = false; #params; - #target; + #dispatch = this.#unboundDispatch.bind(this); constructor(params) { - this.#params = { ...params }; - this.#target = params.target ?? params.host; + this.#params = params; if (this.#params.connected) this.connect(); } @@ -30291,30 +30290,35 @@ class SuperAction { host.removeEventListener(name, this.#dispatch); } } - #dispatch = this.#unboundDispatch.bind(this); #unboundDispatch(event) { - let { type, currentTarget, target } = event; - if (!currentTarget) + dispatch(this.#params, event); + } +} +function dispatch(params, event) { + let { host, target: dispatchTarget = host, infix = ":" } = params; + let { type } = event; + for (let target of event.composedPath()) { + if (!(target instanceof Element)) + continue; + if (target.hasAttribute(`${type}${infix}prevent-default`)) + event.preventDefault(); + if (target.hasAttribute(`${type}${infix}stop-immediate-propagation`)) return; - let { infix = ":" } = this.#params; - for (let node of event.composedPath()) { - if (node instanceof Element) { - if (node.hasAttribute(`${type}${infix}prevent-default`)) - event.preventDefault(); - if (node.hasAttribute(`${type}${infix}stop-immediate-propagation`)) - return; - let actionType = node.getAttribute(`${type}${infix}`); - if (actionType) { - let formData; - if (target instanceof HTMLFormElement) - formData = new FormData(target); - let actionEvent = new ActionEvent({ type: actionType, target: node, event, formData }, { bubbles: true }); - this.#target.dispatchEvent(actionEvent); - } - if (node.hasAttribute(`${type}${infix}stop-propagation`)) - return; - } + let actionType = target.getAttribute(`${type}${infix}`); + if (actionType) { + let formData; + if (target instanceof HTMLFormElement) + formData = new FormData(target); + let actionEvent = new ActionEvent({ + type: actionType, + target, + event, + formData, + }); + dispatchTarget.dispatchEvent(actionEvent); } + if (target.hasAttribute(`${type}${infix}stop-propagation`)) + return; } } diff --git a/examples/form/bundled.js b/examples/form/bundled.js index c8504c4..aa72b39 100644 --- a/examples/form/bundled.js +++ b/examples/form/bundled.js @@ -30266,10 +30266,9 @@ class ActionEvent extends Event { class SuperAction { #connected = false; #params; - #target; + #dispatch = this.#unboundDispatch.bind(this); constructor(params) { - this.#params = { ...params }; - this.#target = params.target ?? params.host; + this.#params = params; if (this.#params.connected) this.connect(); } @@ -30291,30 +30290,35 @@ class SuperAction { host.removeEventListener(name, this.#dispatch); } } - #dispatch = this.#unboundDispatch.bind(this); #unboundDispatch(event) { - let { type, currentTarget, target } = event; - if (!currentTarget) + dispatch(this.#params, event); + } +} +function dispatch(params, event) { + let { host, target: dispatchTarget = host, infix = ":" } = params; + let { type } = event; + for (let target of event.composedPath()) { + if (!(target instanceof Element)) + continue; + if (target.hasAttribute(`${type}${infix}prevent-default`)) + event.preventDefault(); + if (target.hasAttribute(`${type}${infix}stop-immediate-propagation`)) return; - let { infix = ":" } = this.#params; - for (let node of event.composedPath()) { - if (node instanceof Element) { - if (node.hasAttribute(`${type}${infix}prevent-default`)) - event.preventDefault(); - if (node.hasAttribute(`${type}${infix}stop-immediate-propagation`)) - return; - let actionType = node.getAttribute(`${type}${infix}`); - if (actionType) { - let formData; - if (target instanceof HTMLFormElement) - formData = new FormData(target); - let actionEvent = new ActionEvent({ type: actionType, target: node, event, formData }, { bubbles: true }); - this.#target.dispatchEvent(actionEvent); - } - if (node.hasAttribute(`${type}${infix}stop-propagation`)) - return; - } + let actionType = target.getAttribute(`${type}${infix}`); + if (actionType) { + let formData; + if (target instanceof HTMLFormElement) + formData = new FormData(target); + let actionEvent = new ActionEvent({ + type: actionType, + target, + event, + formData, + }); + dispatchTarget.dispatchEvent(actionEvent); } + if (target.hasAttribute(`${type}${infix}stop-propagation`)) + return; } } diff --git a/package-lock.json b/package-lock.json index 1696648..5a6f04b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@w-lfpup/react-superaction", - "version": "0.1.0", + "version": "0.1.1", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@w-lfpup/react-superaction", - "version": "0.1.0", + "version": "0.1.1", "license": "BSD-3-Clause", "dependencies": { - "@w-lfpup/superaction": "^0.4.5" + "@w-lfpup/superaction": "^0.5.1" }, "devDependencies": { "@reduxjs/toolkit": "^2.12.0", @@ -563,9 +563,9 @@ "license": "MIT" }, "node_modules/@w-lfpup/superaction": { - "version": "0.4.6", - "resolved": "https://registry.npmjs.org/@w-lfpup/superaction/-/superaction-0.4.6.tgz", - "integrity": "sha512-UkfAs8iz3/550Ug+CV8TTFaHSWiO3s25VkQo3LhtuoLFDjk/Yo4mRwtpdN+JQTw6Tc93DByCwnD6JeSLbXFBSw==", + "version": "0.5.1", + "resolved": "https://registry.npmjs.org/@w-lfpup/superaction/-/superaction-0.5.1.tgz", + "integrity": "sha512-U8kwr574D3QY8/4oRSST2UvYQF7eWKXb1fSwqhnHUj6yxsla5Q9YJlahsrfXH3lqQ4lwhslE41/Mf9KuOKUvrA==", "license": "BSD-3-Clause" }, "node_modules/commondir": { diff --git a/package.json b/package.json index 981e5d7..88066a9 100644 --- a/package.json +++ b/package.json @@ -32,6 +32,6 @@ "url": "git+https://github.com/w-lfpup/react-superaction.git" }, "dependencies": { - "@w-lfpup/superaction": "^0.4.5" + "@w-lfpup/superaction": "^0.5.1" } }