Allow Function#argumentNames to handle line breaks between arguments.
This commit is contained in:
parent
55af63fdd6
commit
206a4c824f
@ -1,3 +1,5 @@
|
||||
* Allow Function#argumentNames to handle line breaks between arguments. (Geoff M. Granum, Tobie Langel) [#63 state:resolved]
|
||||
|
||||
* For consistency, add additional optional parameter "context" to Number.prototype.times. (Samuel Lebeau)
|
||||
|
||||
* Replace all instances of foo.__proto__ by foo['__proto__'] for Caja-compliance. (Tobie Langel)
|
||||
|
@ -159,7 +159,8 @@ Object.extend(Object, {
|
||||
|
||||
Object.extend(Function.prototype, {
|
||||
argumentNames: function() {
|
||||
var names = this.toString().match(/^[\s\(]*function[^(]*\(\s*(.*?)\s*\)/)[1].split(/\s*,\s*/);
|
||||
var names = this.toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1]
|
||||
.replace(/\s+/g, '').split(',');
|
||||
return names.length == 1 && !names[0] ? [] : names;
|
||||
},
|
||||
|
||||
|
@ -3,7 +3,8 @@ new Test.Unit.Runner({
|
||||
this.assertEnumEqual([], (function() {}).argumentNames());
|
||||
this.assertEnumEqual(["one"], (function(one) {}).argumentNames());
|
||||
this.assertEnumEqual(["one", "two", "three"], (function(one, two, three) {}).argumentNames());
|
||||
this.assertEnumEqual(["one", "two", "three"], (function( one , two , three ) {}).argumentNames());
|
||||
this.assertEnumEqual(["one", "two", "three"], (function( one , two
|
||||
, three ) {}).argumentNames());
|
||||
this.assertEqual("$super", (function($super) {}).argumentNames().first());
|
||||
|
||||
function named1() {};
|
||||
|
Loading…
Reference in New Issue
Block a user