fix: add warnings when click delegates return non-booleans (#1319)

This commit is contained in:
Nolan Lawson 2019-07-07 18:26:06 -07:00 committed by GitHub
parent cfc182a836
commit 8615c6e4fd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -28,7 +28,11 @@ function onEvent (e) {
return // ignore if the user is selecting text inside the clickable area return // ignore if the user is selecting text inside the clickable area
} }
} }
if (callbacks[key](e)) { // callback returns true to indicate it has handled the action let res = callbacks[key](e) // callback returns true to indicate it has handled the action
if (process.env.NODE_ENV !== 'production' && typeof res !== 'boolean') {
console.warn(`Callback returned a non-boolean response: "${key}". This should never happen.`)
}
if (res) {
e.preventDefault() e.preventDefault()
e.stopPropagation() e.stopPropagation()
} }