Closed Bug 373994 Opened 17 years ago Closed 12 years ago

Uneval of E4X changes whitespace, losing information

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED WONTFIX

People

(Reporter: jruderman, Unassigned)

References

Details

(Keywords: testcase)

js> a = <x>t</x>;
t

js> b = <x>t </x>
t 

js> a == b
false

js> uneval(a) == uneval(b)
true

js> eval(uneval(a)) == eval(uneval(b))
true
eval(true) is always true -- did you forget to quote the argument to eval in the last js> line?

The rest follows from the definition of == for strings vs. objects.

/be
I think Jesse was noting this:
js> uneval(<x>t </x>)
<x>t</x>

Note the loss of the whitespace.
Sure, but that last eval is just being given true and returning it immediately.

Yes, the de-facto E4X standard is to chomp whitespace in simple text content. This has been a spec violation, but the tests and Rhino wanted it. I hope my memory is working. Jeff Walden and David Caldwell know all.

/be
> That last eval is just being given true and returning it immediately.

Are you sure?

js> a = <x>t</x>;
t
js> uneval(a)
<x>t</x>
js> eval(uneval(a))
t
Sorry, I'm blind (jetlagged).

What your latest comment shows is E4X's toString being clever. If you want the markup, use toXMLString.

/be
This happens even when XML.ignoreWhitespace is false.  (Based on my reading the spec, XML.ignoreWhitespace shouldn't matter in this case, since the whitespace is next to text.)

js> XML.ignoreWhitespace = false
false
js> uneval(<x> t </x>)
<x>t</x>
(In reply to comment #3)
> Yes, the de-facto E4X standard is to chomp whitespace in simple text content.
> This has been a spec violation, but the tests and Rhino wanted it. I hope my
> memory is working. Jeff Walden and David Caldwell know all.

There is some discussion of this topic appended to bugs 369394 and bug 368435.  So yeah, the decision is that the spec (meaning ECMA-357) is wrong and the code is essentially the spec as pertains to your point here.  I would argue that the case show in in comment 6 is a bug, but that the previous ones are not.

Rhino has much bigger problems than SpiderMonkey here, apparently:

* * *
inonit@inonit /opt/java/rhino/HEAD.2007-03-01/rhino/build/rhino1_6R6pre
$ $jdk/bin/java -jar js.jar
Rhino 1.6 release 6 Pre 2007 03 07
js> uneval(<x> t </x>)
({0:{}})
* * *

Wow.

By the way, does anyone object if I re-open bug 368435 and close bug 369394 as invalid, based on our previous discussions?  We forgot to do this.
I've created bug 374047 to represent Rhino's issues with E4X uneval().
Blocks: e4x
OS: Mac OS X → All
Hardware: x86 → All
E4X will be removed again from Spidermonkey (bug 788293)
Status: NEW → RESOLVED
Closed: 12 years ago
Resolution: --- → WONTFIX
You need to log in before you can comment on or make changes to this bug.