Skip to content

Commit 26da479

Browse files
committed
Fixed bug and adjusted specs for around autoclear = false.
1 parent cde6bca commit 26da479

File tree

3 files changed

+14
-6
lines changed

3 files changed

+14
-6
lines changed

spec/Enter.Spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ feature("Enter Key", function() {
3737
input.trigger(enterKeyEvent);
3838
});
3939
then("value should remain visible with placeholders",function(){
40-
expect(input).toHaveValue("1_");
40+
expect(input).toHaveValue("1");
4141
});
4242
});
4343
});
@@ -63,7 +63,7 @@ feature("Enter Key", function() {
6363
input.mashKeys("1").trigger(enterKeyEvent);
6464
});
6565
then("value should be empty",function(){
66-
expect(input).toHaveValue("1___");
66+
expect(input).toHaveValue("1");
6767
});
6868
});
6969

spec/Focus.Spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ feature("Leaving A Masked Input",function(){
123123
input.blur();
124124
});
125125
then("value should remain visible with placeholders",function(){
126-
expect(input).toHaveValue("1_");
126+
expect(input).toHaveValue("1");
127127
});
128128
});
129129
});
@@ -149,7 +149,7 @@ feature("Optional marker",function(){
149149
input.mashKeys("1").blur();
150150
});
151151
then("value should be empty",function(){
152-
expect(input).toHaveValue("1___");
152+
expect(input).toHaveValue("1");
153153
});
154154
});
155155

src/jquery.maskedinput.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,11 @@
133133

134134
var trimmed=buffer;
135135
if(this.partialPosition < this.length){
136-
trimmed=buffer.slice(0, Math.max(this.partialPosition,lastMatch+1))
136+
trimmed = buffer.slice(0, Math.max(this.partialPosition,lastMatch+1))
137+
}
138+
139+
if(!this.settings.autoclear){
140+
trimmed = buffer.slice(0,i);
137141
}
138142

139143
//TODO: better names for these props
@@ -324,7 +328,11 @@
324328
//Apply initital mask
325329
if(elm.value.length){
326330
var result=mask.apply(elm.value);
327-
elm.value = result.value;
331+
if(!settings.autoclear || result.isComplete){
332+
elm.value = result.value;
333+
}else{
334+
elm.value="";
335+
}
328336
}
329337
});
330338
}

0 commit comments

Comments
 (0)