Skip to content

Commit

Permalink
Add support for self reference in the effect
Browse files Browse the repository at this point in the history
Fix #290
  • Loading branch information
titouanmathis committed Aug 9, 2024
1 parent 3f7adfc commit 0eac076
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/ui/atoms/Action/Action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export class Action<T extends BaseProps = BaseProps> extends Base<ActionProps &
get effect() {
const { effect } = this.$options;
if (!effectCache.has(effect)) {
effectCache.set(effect, new Function('ctx', 'event', 'target', `return ${effect}`));
effectCache.set(effect, new Function('ctx', 'event', 'target', 'action', `return ${effect}`));
}
return effectCache.get(effect);
}
Expand Down Expand Up @@ -93,10 +93,10 @@ export class Action<T extends BaseProps = BaseProps> extends Base<ActionProps &

for (const target of targets) {
try {
const [name, currentTarget] = Object.entries(target).flat();
const value = effect(target, event, currentTarget);
const [currentTarget] = Object.values(target).flat();
const value = effect(target, event, currentTarget, this);
if (typeof value === 'function') {
value(target, event, currentTarget);
value(target, event, currentTarget, this);
}
} catch (err) {
this.$warn(err);
Expand Down

0 comments on commit 0eac076

Please sign in to comment.