Skip to content

Commit

Permalink
Fix array events not supposed treated as an object (#34)
Browse files Browse the repository at this point in the history
* fix: updated array type event

* not supposed to be treated as object spread

* chore: added changelog
  • Loading branch information
oknoorap committed Sep 4, 2023
1 parent 60fe19e commit 7baab6c
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/red-horses-rule.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@realmorg/realm": patch
---

Update fix array type event
14 changes: 10 additions & 4 deletions packages/realm/src/actions/script-flow.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ export const scriptAction = defineAction({
RealmAttributeNames.SCRIPT_ID
);

const hasEventTarget = !!event?.target;
const eventTarget = Object.freeze(event?.target);
const waitForScriptLoaded = () =>
reqAnim(() => {
Expand All @@ -69,10 +70,15 @@ export const scriptAction = defineAction({
if (!isScriptLoaded) return waitForScriptLoaded();
scriptFlow?.apply(
element,
getScriptArgs(element, {
...event,
target: eventTarget,
})
getScriptArgs(
element,
!hasEventTarget
? event
: {
...event,
target: eventTarget,
}
)
);
});
waitForScriptLoaded();
Expand Down

0 comments on commit 7baab6c

Please sign in to comment.