Skip to content

Commit 55c0738

Browse files
author
Igor Escobar
authored
Merge pull request #711 from csmith93/master
Fix issue preventing calculateCaretPosition from calculating correctly.
2 parents 44299ed + 19a8b29 commit 55c0738

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/jquery.mask.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -187,9 +187,8 @@
187187

188188
return r;
189189
},
190-
calculateCaretPosition: function() {
191-
var oldVal = el.data('mask-previus-value') || '',
192-
newVal = p.getMasked(),
190+
calculateCaretPosition: function(oldVal) {
191+
var newVal = p.getMasked(),
193192
caretPosNew = p.getCaret();
194193
if (oldVal !== newVal) {
195194
var caretPosOld = el.data('mask-previus-caret-pos') || 0,
@@ -255,12 +254,13 @@
255254

256255
if ($.inArray(keyCode, jMask.byPassKeys) === -1) {
257256
var newVal = p.getMasked(),
258-
caretPos = p.getCaret();
257+
caretPos = p.getCaret(),
258+
oldVal = el.data('mask-previus-value') || '';
259259

260260
// this is a compensation to devices/browsers that don't compensate
261261
// caret positioning the right way
262262
setTimeout(function() {
263-
p.setCaret(p.calculateCaretPosition());
263+
p.setCaret(p.calculateCaretPosition(oldVal));
264264
}, $.jMaskGlobals.keyStrokeCompensation);
265265

266266
p.val(newVal);

0 commit comments

Comments
 (0)