Skip to content

Commit

Permalink
fix focus in and out
Browse files Browse the repository at this point in the history
  • Loading branch information
JoviDeCroock committed Mar 21, 2024
1 parent b820d8b commit ab36dbe
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/diff/props.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ export function setProperty(dom, name, value, oldValue, isSvg) {
name !== (name = name.replace(/(PointerCapture)$|Capture$/i, '$1'));

// Infer correct casing for DOM built-in events:
if (name.toLowerCase() in dom) name = name.toLowerCase().slice(2);
if (
name.toLowerCase() in dom ||
name === 'onFocusOut' ||
name === 'onFocusIn'
)
name = name.toLowerCase().slice(2);
else name = name.slice(2);

if (!dom._listeners) dom._listeners = {};
Expand Down
8 changes: 8 additions & 0 deletions test/browser/events.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -227,4 +227,12 @@ describe('event handling', () => {
.to.have.been.calledTwice.and.to.have.been.calledWith('gotpointercapture')
.and.calledWith('lostpointercapture');
});

it.only('should support camel-case focus event names', () => {

Check failure on line 231 in test/browser/events.test.js

View workflow job for this annotation

GitHub Actions / Build & Test

Unexpected focused test

Check failure on line 231 in test/browser/events.test.js

View workflow job for this annotation

GitHub Actions / Build & Test / Build & Test

Unexpected focused test
render(<div onFocusIn={() => {}} onFocusOut={() => {}} />, scratch);

expect(proto.addEventListener)
.to.have.been.calledTwice.and.to.have.been.calledWith('focusin')
.and.calledWith('focusout');
});
});

0 comments on commit ab36dbe

Please sign in to comment.