function.toString() has extra newline at top, bottom

VERIFIED DUPLICATE of bug 111816

Status

()

Core
JavaScript Engine
--
minor
VERIFIED DUPLICATE of bug 111816
16 years ago
16 years ago

People

(Reporter: Jesse Ruderman, Assigned: Kenton Hanson (gone))

Tracking

Trunk
x86
Windows 98
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

(URL)

(Reporter)

Description

16 years ago
function.toString includes a newline below and above the function.  This makes
the output of the "view variables" bookmarklet more ugly than it would be
otherwise. (http://www.squarefree.com/bookmarklets/webdevel.html)

Testcase:
javascript:function s(){}; alert("*" + s.toString() + "*")

Opera and Netscape 4 also have this bug, but Internet Explorer does not.

Comment 1

16 years ago
i don't see extra newline below the function, however I see newline above the
function ...

*

function S {
}
*

this is what i get ....

Comment 2

16 years ago
Here is a javascript:URL which counts the lines for us:
javascript:function f(){}; alert(f.toString().split('\n').length)
We get these results:   NN4.7    IE6   Moz/N6
                         4       1      4


Here is another test showing what Jesse means:
javascript:function f(){}; var a = f.toString().split('\n'); var s = '';
for (var i in a) {s+= ('a[' + i + '] = '  + a[i] + '\n');}; alert(s);

IE6                           Moz/N6
a[0] = function f(){}         a[0] =
                              a[1] = function f() {
                              a[2] = }
                              a[3] =



As it stands, we could mark this one invalid, since the ECMA spec
is quite specific that this is OK:

15.3.4.2 Function.prototype.toString ( )

An implementation-dependent representation of the function is returned.
This representation has the syntax of a FunctionDeclaration. Note in
particular that the use and placement of white space, line terminators,
and semicolons within the representation string is implementation-dependent.



However, let me keep this one open for consideration and cc Brendan
on it. Should we keep the extra newlines above and below f.toString()?
Assignee: rogerl → khanson
Summary: function.toString has extra newline at top, bottom → function.toString() has extra newline at top, bottom
This issue we discussed November of last year, via bug 111816.  Brendan said "no".

Out of respect to pschwartau, I won't mark this bug a duplicate just yet.  But
it clearly is.

Comment 4

16 years ago
Alex is exactly right; marking as duplicate. Jesse, please see
the discussion in that bug; thanks - 

*** This bug has been marked as a duplicate of 111816 ***
Status: NEW → RESOLVED
Last Resolved: 16 years ago
Resolution: --- → DUPLICATE

Comment 5

16 years ago
Marking Verified Duplicate -
Status: RESOLVED → VERIFIED
You need to log in before you can comment on or make changes to this bug.