Skip to content
This repository has been archived by the owner on Aug 27, 2023. It is now read-only.

Commit

Permalink
added support for event listerens
Browse files Browse the repository at this point in the history
  • Loading branch information
yurii-sorokin committed Feb 21, 2018
1 parent afbb5ee commit ca5318d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/extract-props.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ const getBoundStyles = (debugNode) => {
.map(styleRule => `${styleRule}: ${styles[styleRule]}`)
}

const getListeners = (debugNode) => {
const { listeners = [] } = debugNode
return listeners
.reduce((map, listener) => ({ ...map, [listener.name]: listener.callback }), {})
}

const rClassSplitter = /\s+/
const rStyleSplitter = /\s+;\s+/
const classSplitter = ' '
Expand All @@ -38,7 +44,8 @@ const getProps = (debugNode) => {
...properties,
...attributes,
...(allClasses.length ? { 'class': allClasses.join(classSplitter) } : {}),
...(allStyles.length ? { style: allStyles.join(styleSplitter) } : {})
...(allStyles.length ? { style: allStyles.join(styleSplitter) } : {}),
...getListeners(debugNode)
}, ignoredProps)
}

Expand Down

0 comments on commit ca5318d

Please sign in to comment.