Fix issue where Function#argumentNames returned incorrect results in IE when comments were intermixed with argument names. [#397 state:resolved]
This commit is contained in:
parent
c039f68fb7
commit
54bf343560
@ -1,3 +1,5 @@
|
||||
* Fix issue where Function#argumentNames returned incorrect results in IE when comments were intermixed with argument names. (Christophe Porteneuve, T.J. Crowder)
|
||||
|
||||
* Selector.patterns should be represented as an ordered structure. (ADO, kangax)
|
||||
|
||||
* Performance improvements in Function methods (Samuel Lebeau, kangax, jddalton, Tobie Langel).
|
||||
|
@ -13,7 +13,8 @@ Object.extend(Function.prototype, (function() {
|
||||
}
|
||||
|
||||
function argumentNames() {
|
||||
var names = this.toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1]
|
||||
var names = this.toString().match(/^[\s\(]*function[^(]*\(([^)]*)\)/)[1]
|
||||
.replace(/\/\/.*?[\r\n]|\/\*(?:.|[\r\n])*?\*\//g, '')
|
||||
.replace(/\s+/g, '').split(',');
|
||||
return names.length == 1 && !names[0] ? [] : names;
|
||||
}
|
||||
|
@ -13,6 +13,16 @@ new Test.Unit.Runner({
|
||||
this.assertEnumEqual(["one"], named2.argumentNames());
|
||||
function named3(one, two, three) {};
|
||||
this.assertEnumEqual(["one", "two", "three"], named3.argumentNames());
|
||||
function named4(/*foo*/ foo, /* bar */ bar, /*****/ baz) {}
|
||||
this.assertEnumEqual($w("foo bar baz"), named4.argumentNames());
|
||||
|
||||
function named5(
|
||||
/*foo*/ foo,
|
||||
/**/bar,
|
||||
/* baz */ /* baz */ baz,
|
||||
// Skip a line just to screw with the regex...
|
||||
/* thud */ thud) {}
|
||||
this.assertEnumEqual($w("foo bar baz thud"), named5.argumentNames());
|
||||
},
|
||||
|
||||
testFunctionBind: function() {
|
||||
|
Loading…
Reference in New Issue
Block a user