浏览代码

This line of code returns an unexpected value when unmasking as number fix #1527

Robin Herbots 8 年之前
父节点
当前提交
abfbb8047f
共有 2 个文件被更改,包括 7 次插入7 次删除
  1. 1 0
      CHANGELOG.md
  2. 6 7
      js/inputmask.js

+ 1 - 0
CHANGELOG.md

@@ -8,6 +8,7 @@ All notable changes to this project will be documented in this file.
 	- initialization
 
 ### Fixed
+- This line of code returns an unexpected value when unmasking as number #1527
 - Phone Mask Cursor Issue on Chrome on some Androids.. #1490
 - min value issue fix #1177
 - static is a reserved keyword #1479

+ 6 - 7
js/inputmask.js

@@ -1312,10 +1312,10 @@
 						//return is false or a json object => { pos: ??, c: ??} or true
 						rslt = test.fn != null ?
 							test.fn.test(chrs, getMaskSet(), position, strict, opts, isSelection(pos)) : (c === test.def || c === opts.skipOptionalPartCharacter) && test.def !== "" ? //non mask
-						{
-							c: getPlaceholder(position, test, true) || test.def,
-							pos: position
-						} : false;
+							{
+								c: getPlaceholder(position, test, true) || test.def,
+								pos: position
+							} : false;
 
 						if (rslt !== false) {
 							var elem = rslt.c !== undefined ? rslt.c : c;
@@ -1728,12 +1728,11 @@
 			}
 			input.inputmask._valueSet(buffer.join(""));
 			if (caretPos !== undefined && (event === undefined || event.type !== "blur")) {
-				caret(input, caretPos);
 				if (android && event.type === "input") {
 					setTimeout(function () {
 						caret(input, caretPos);
 					}, 0);
-				}
+				} else caret(input, caretPos);
 			} else renderColorMask(input, buffer, caretPos);
 			if (triggerInputEvent === true) {
 				skipInputEvent = true;
@@ -1871,7 +1870,7 @@
 			var unmaskedValue = umValue.length === 0 ? "" : (isRTL ? umValue.reverse() : umValue).join("");
 			if ($.isFunction(opts.onUnMask)) {
 				var bufferValue = (isRTL ? getBuffer().slice().reverse() : getBuffer()).join("");
-				unmaskedValue = (opts.onUnMask(bufferValue, unmaskedValue, opts) || unmaskedValue);
+				unmaskedValue = opts.onUnMask(bufferValue, unmaskedValue, opts);
 			}
 			return unmaskedValue;
 		}