Skip to content

Commit

Permalink
Make Function#argumentNames use Function.prototype.toString. [#186 st…
Browse files Browse the repository at this point in the history
…ate:resolved]
  • Loading branch information
savetheclocktower committed Jun 26, 2008
1 parent 6f79c78 commit 05a1143
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
@@ -1,3 +1,5 @@
* Make Function#argumentNames use Function.prototype.toString. [Garrett Smith, jddalton, kangax]

* Rename variable in Form.Element.Serializers.select. [jddalton]

* Replace browser sniffing with capability detection in IE fork of String#unescapeHTML. [kangax]
Expand Down
7 changes: 4 additions & 3 deletions src/base.js
Expand Up @@ -158,9 +158,10 @@ Object.extend(Object, {
});

Object.extend(Function.prototype, {
argumentNames: function() {
var names = this.toString().match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1]
.replace(/\s+/g, '').split(',');
argumentNames: function() {
var names = Function.prototype.toString.call(this)
.match(/^[\s\(]*function[^(]*\(([^\)]*)\)/)[1]
.replace(/\s+/g, '').split(',');
return names.length == 1 && !names[0] ? [] : names;
},

Expand Down

2 comments on commit 05a1143

@tobie
Copy link
Collaborator

@tobie tobie commented on 05a1143 Sep 8, 2008

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’d like to discuss this before we apply it as this is one of the rare cases which aren’t part of ECMAScript 3.1 strict mode but which would nevertheless break Caja.

@kangax
Copy link
Collaborator

@kangax kangax commented on 05a1143 Sep 8, 2008

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tobie, how would this break Caja?

Please sign in to comment.