Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
52 changes: 28 additions & 24 deletions examples/counter/bundled.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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;
}
}

Expand Down
52 changes: 28 additions & 24 deletions examples/form/bundled.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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;
}
}

Expand Down
12 changes: 6 additions & 6 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
}