Skip to content

Commit

Permalink
createElement handle listeners
Browse files Browse the repository at this point in the history
  • Loading branch information
ericfortis committed Sep 30, 2023
1 parent f9deb6f commit 9af673c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions react-create-element/createElement.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ function createElement(tagName, props, ...children) {
const elem = document.createElement(tagName)
if (props)
for (const [key, value] of Object.entries(props))
if (key === 'onChange')
elem.addEventListener('change', value)
else if (key === 'onClick')
elem.addEventListener('click', value)
if (key.startsWith('on'))
elem.addEventListener(key.replace(/^on/, '').toLowerCase(), value);
else if (key === 'ref')
value.current = elem
else if (key === 'style')
Expand Down

0 comments on commit 9af673c

Please sign in to comment.