From 9d5db8a3450bd8e05e700efdaeba4b71dbb84fd4 Mon Sep 17 00:00:00 2001 From: jahorton Date: Thu, 11 Feb 2021 13:20:42 +0700 Subject: [PATCH] change(common/core/web): includes review suggestion --- common/core/web/keyboard-processor/src/text/outputTarget.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/common/core/web/keyboard-processor/src/text/outputTarget.ts b/common/core/web/keyboard-processor/src/text/outputTarget.ts index 8b1cd85205..64c12ea5cf 100644 --- a/common/core/web/keyboard-processor/src/text/outputTarget.ts +++ b/common/core/web/keyboard-processor/src/text/outputTarget.ts @@ -288,8 +288,8 @@ namespace com.keyman.text { this.text = text ? text : ""; var defaultLength = this.text._kmwLength(); - // An index of 0 should still be considered 'defined', while null and undefined... not so much. - this.caretIndex = (caretPos || caretPos === 0) ? caretPos : defaultLength; + // Ensures that `caretPos == 0` is handled correctly. + this.caretIndex = typeof caretPos == "number" ? caretPos : defaultLength; } // Clones the state of an existing EditableElement, creating a Mock version of its state.