prototype: Make sure $w always returns an array.
This commit is contained in:
parent
0632778884
commit
865ac01937
|
@ -1,5 +1,7 @@
|
|||
*SVN*
|
||||
|
||||
* Make sure $w always returns an array. [Andrew Dupont, Tobie Langel]
|
||||
|
||||
* Add more tests to Hash. [Mislav Marohnić]
|
||||
|
||||
* Performance enhancements to $A. Closes #9464. [Samuel Lebeau]
|
||||
|
|
|
@ -128,6 +128,7 @@ if (!Array.prototype.lastIndexOf) Array.prototype.lastIndexOf = function(item, i
|
|||
Array.prototype.toArray = Array.prototype.clone;
|
||||
|
||||
function $w(string) {
|
||||
if (!Object.isString(string)) return [];
|
||||
string = string.strip();
|
||||
return string ? string.split(/\s+/) : [];
|
||||
}
|
||||
|
|
|
@ -204,6 +204,11 @@
|
|||
test$w: function(){ with(this) {
|
||||
assertEnumEqual(['a', 'b', 'c', 'd'], $w('a b c d'));
|
||||
assertEnumEqual([], $w(' '));
|
||||
assertEnumEqual([], $w(''));
|
||||
assertEnumEqual([], $w(null));
|
||||
assertEnumEqual([], $w(undefined));
|
||||
assertEnumEqual([], $w());
|
||||
assertEnumEqual([], $w(10));
|
||||
assertEnumEqual(['a'], $w('a'));
|
||||
assertEnumEqual(['a'], $w('a '));
|
||||
assertEnumEqual(['a'], $w(' a'));
|
||||
|
|
Loading…
Reference in New Issue