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
1 changed files with 5 additions and 1 deletions

View File

@ -28,7 +28,11 @@ function onEvent (e) {
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.stopPropagation()
}