Closed
Bug 86166
Opened 24 years ago
Closed 24 years ago
<script language="Javascript1.2"> causes incompatible result format of Array.prototype.toString()
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
VERIFIED
WONTFIX
People
(Reporter: andorxor, Assigned: rogerl)
Details
(Whiteboard: [js1.2])
Attachments
(3 files)
When a script is included with language="JavaScript1.2" Mozilla
Array.prototype.toString's behaviour is incompatible to the one of IE,
Navigator 4 and to what ECMA says.
Sample code:
var s = "string";
var a = [s];
alert(a);
//IE and Navigator 4 show 'string' (without the outer quotation marks)
//Mozilla shows '["string"]'
//ECMA: toString() has to be the same as join()
A more elaborate example is attached.
| Reporter | ||
Comment 1•24 years ago
|
||
Comment 2•24 years ago
|
||
When you do "alert(a)", you are implicitly doing a.toString().
In JS 1.2, Array.toString() functioned like Array.toSource() does now:
that is, it gave something you could recompile back into the array.
This is specific to version 1.2.
| Reporter | ||
Comment 3•24 years ago
|
||
Apparently this is specific to JavaScript 1.2 as it is implemented in Mozilla.
But why should Array.toString() function in JS 1.2 like Array.toSource()?
In IE4+, Nav4+ and even Navigator3 Array.toString() is implemented to function
like Array.join().
Comment 4•24 years ago
|
||
> But why should Array.toString() function in JS 1.2 like Array.toSource()?
This was a decision made at Netscape years ago. There are at least
two major implementations of JavaScript: one by Netscape (where JavaScript
was created, by Brendan Eich) and one by Microsoft. The two implementaions
differ from each other in slight ways.
The ECMA standard has also changed over time. What the standard says now
is not necessarily what it said at the time JS1.2 was being developed.
In the Netscape implementation, version 1.2 of the language differs
in some noticeable ways from all other Netscape versions, and you have
discovered one of these ways.
I will attach an HTML testcase that shows another technical difference
between Netscape JS1.2 and all other Netscape versions (and IE JS1.2).
You can try this testcase in IE, NN4.x, and Mozilla/N6.
Comment 5•24 years ago
|
||
Comment 6•24 years ago
|
||
You raise an interesting question: why does Mozilla behave differently
on your testcase than NN4.7? It is understandable if IE behaves
differently, because Microsoft JavaScript 1.2 is not identical to
Netcape JavaScript 1.2. But why should NN4.7 and Mozilla behave
differently? This is a good question!
I will attach a reduced version of your testcase below with the
<style> and <div> tags removed. Only the JavaScript remains.
Now we see NO difference between NN4.7 and Mozilla!!!
NN4.7 shows '["string"]'
Mozilla shows '["string"]'
Comment 7•24 years ago
|
||
Comment 8•24 years ago
|
||
Stephan, thank you for this report!
But I have to mark this bug as WONTFIX. The behavior of JS1.2 was decided
at Netscape (and Microsoft) years ago. Many web pages have been written
since that time with <script language="Javascript1.2">. We cannot change
Netscape JS1.2 now without breaking web pages that rely on its behavior.
Any new web page that does not need to use the features of a particular
version of JavaScript should always use <script language="Javascript">.
Status: UNCONFIRMED → RESOLVED
Closed: 24 years ago
Resolution: --- → WONTFIX
Comment 9•24 years ago
|
||
Marking Verified.
Note: the bug with NN4.x on your testcase is real, in my opinion.
But bugs against NN4.x are not for Bugzilla. Here is a URL for that:
http://help.netscape.com/forms/bug-client.html
Again, thank you for helping us. It is contributors like you who
catch the things we miss -
Status: RESOLVED → VERIFIED
Updated•21 years ago
|
Whiteboard: [js1.2]
You need to log in
before you can comment on or make changes to this bug.
Description
•