Closed
Bug 300413
Opened 21 years ago
Closed 21 years ago
E4X: Can't find XML object's methods in the 'with' statement
Categories
(Core :: JavaScript Engine, defect)
Tracking
()
VERIFIED
INVALID
People
(Reporter: nanto, Unassigned)
References
Details
Attachments
(1 file)
|
1.22 KB,
text/html
|
Details |
User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; ja-JP; rv:1.7.8) Gecko/20050511 Firefox/1.0.4
Build Identifier: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8b3) Gecko/20050709 Firefox/1.0+
In the 'with' statement, an unqualified name function is interpretted as a
method of the given object if the object has the same name method. But when an
object of XML type is given to the 'with' statement, any method of the object is
not called without a qualifier.
Reproducible: Always
Steps to Reproduce:
1. Execute the following script.
2.
3.
var x = <element>content</element>;
with (x) alert(toString());
Actual Results:
"[object Window]"
Expected Results:
"content"
| Reporter | ||
Comment 1•21 years ago
|
||
Comment 2•21 years ago
|
||
Blame ECMA-357 for this: it explicitly removes XML.prototype's methods from the
default namespace, isolating them behind a magic [[Call]] internal method so
that they are not visible to [[HasProperty]], [[Get]], or [[Put]]. So per the
spec, you can only call XML methods directly -- you cannot capture references to
them by their unqualified names, or use apply or call from Function.prototype to
invoke one on an argument list.
There is talk in ECMA TG1 of supporting a magic namespace by which you can
access methods as first-class values, not merely call them directly. I have
prototyped such a namespace, identified by the function reserved identifier as
namespace, in SpiderMonkey, as shown by this shell session:
$ cat e4xduh.js
var x = <element>content</element>;
with (x) print(function::toString());
$ Linux_All_DBG.OBJ/js -x -f e4xduh.js
content
/be
Status: UNCONFIRMED → RESOLVED
Closed: 21 years ago
Resolution: --- → INVALID
| Reporter | ||
Comment 3•21 years ago
|
||
Oh, sorry. I've missed the specification.
ECMA-357 9.1.1.1 says:
NOTE Unlike the internal Object [[Get]] method, the internal XML [[Get]] method
is never used for retrieving methods associated with XML objects.
Status: RESOLVED → VERIFIED
You need to log in
before you can comment on or make changes to this bug.
Description
•