Skip to content

Commit f20fe4b

Browse files
committed
optimizing replace method for xul browsers
1 parent 70ba6b7 commit f20fe4b

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

jquery-textrange.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,8 +129,11 @@
129129
},
130130

131131
replace: function(text) {
132+
text = String(text);
132133
var start = this[0].selectionStart;
133-
this.val(this.val().substring(0, this[0].selectionStart) + text + this.val().substring(this[0].selectionEnd, this.val().length));
134+
var end = this[0].selectionEnd;
135+
var val = this.val();
136+
this.val(val.substring(0, start) + text + val.substring(end, val.length));
134137
this[0].selectionStart = start;
135138
this[0].selectionEnd = start + text.length;
136139
}

0 commit comments

Comments
 (0)