Skip to content

Commit

Permalink
Add changelog and rename var
Browse files Browse the repository at this point in the history
  • Loading branch information
cbravobernal committed May 7, 2024
1 parent b7ffc09 commit 19cd289
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
4 changes: 4 additions & 0 deletions packages/interactivity/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## Unreleased

### Bug Fixes

- Allow multiple event handlers for the same type with `data-wp-on-document` and `data-wp-on-window`. ([#61009](https://github.com/WordPress/gutenberg/pull/61009))

## 5.6.0 (2024-05-02)

## 5.5.0 (2024-04-19)
Expand Down
8 changes: 4 additions & 4 deletions packages/interactivity/src/directives.js
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,12 @@ const getGlobalEventDirective = ( type ) => {
directives[ `on-${ type }` ]
.filter( ( { suffix } ) => suffix !== 'default' )
.forEach( ( entry ) => {
const event = entry.suffix.split( '--', 1 )[ 0 ];
const eventName = entry.suffix.split( '--', 1 )[ 0 ];
useInit( () => {
const cb = ( cbEvent ) => evaluate( entry, cbEvent );
const cb = ( event ) => evaluate( entry, event );
const globalVar = type === 'window' ? window : document;
globalVar.addEventListener( event, cb );
return () => globalVar.removeEventListener( event, cb );
globalVar.addEventListener( eventName, cb );
return () => globalVar.removeEventListener( eventName, cb );
}, [] );
} );
};
Expand Down

0 comments on commit 19cd289

Please sign in to comment.