Fix an issue with String.prototype.endsWith. Closes #7822. [altblue]
This commit is contained in:
parent
63985a21ed
commit
fc91a3e456
|
@ -1,3 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Fix an issue with String.prototype.endsWith. Closes #7822. [altblue]
|
||||
|
||||
*1.5.1_rc2* (March 12, 2007)
|
||||
|
||||
* Add a tab character via innerHTML to the selector whitespace test. [Christophe Porteneuve]
|
||||
|
|
|
@ -176,11 +176,12 @@ Object.extend(String.prototype, {
|
|||
},
|
||||
|
||||
startsWith: function(pattern) {
|
||||
return this.indexOf(pattern) == 0;
|
||||
return this.indexOf(pattern) === 0;
|
||||
},
|
||||
|
||||
endsWith: function(pattern) {
|
||||
return this.lastIndexOf(pattern) == (this.length - pattern.length);
|
||||
var d = this.length - pattern.length;
|
||||
return d >= 0 && this.lastIndexOf(pattern) === d;
|
||||
},
|
||||
|
||||
empty: function() {
|
||||
|
|
|
@ -342,6 +342,7 @@
|
|||
assert('hello world'.startsWith('hello'));
|
||||
assert(!'hello world'.startsWith('bye'));
|
||||
assert(!''.startsWith('bye'));
|
||||
assert(!'hell'.startsWith('hello'));
|
||||
}},
|
||||
|
||||
testEndsWith: function() {with(this) {
|
||||
|
@ -350,6 +351,7 @@
|
|||
assert(!'hello world'.endsWith('planet'));
|
||||
assert(!''.endsWith('planet'));
|
||||
assert('hello world world'.endsWith(' world'));
|
||||
assert(!'z'.endsWith('az'));
|
||||
}},
|
||||
|
||||
testBlank: function() { with(this) {
|
||||
|
|
Loading…
Reference in New Issue