1
0
mirror of https://github.com/ianstormtaylor/slate.git synced 2025-08-18 05:01:17 +02:00

Warn during normalization when range offsets are not numbers. (#1578)

This commit is contained in:
Jamie Talbot
2018-02-02 10:19:01 -08:00
committed by Ian Storm Taylor
parent 85b4f2f495
commit c044d048ad

View File

@@ -675,6 +675,12 @@ class Range extends Record(DEFAULTS) {
const range = this
let { anchorKey, anchorOffset, focusKey, focusOffset, isBackward } = range
const anchorOffsetType = typeof anchorOffset
const focusOffsetType = typeof focusOffset
if (anchorOffsetType != 'number' || focusOffsetType != 'number') {
logger.warn(`The range offsets should be numbers, but they were of type "${anchorOffsetType}" and "${focusOffsetType}".`)
}
// If the range is unset, make sure it is properly zeroed out.
if (anchorKey == null || focusKey == null) {
return range.merge({