为什么此 E4X 代码不尊重默认命名空间?
我正在修改 Firefox 扩展,尝试使用 E4X。 然而,我遇到了一个奇怪的问题:
var myXml = <test xmlns="http://test.com">
Hey
<inner>
Guys
</inner>
</test>;
var ns = myXml.namespace();
default xml namespace = ns;
this.log(myXml.*::inner);
this.log(myXml.ns::inner);
this.log(myXml.inner);
前两个日志语句打印“Guys”。 第三个是空白。 这是怎么回事? 我已经指定了默认命名空间,它实际上与我在第二条日志语句中使用的完全相同。 为什么这不起作用?
I'm hacking around in a Firefox extension, trying to use E4X. However, I've come across a weird problem:
var myXml = <test xmlns="http://test.com">
Hey
<inner>
Guys
</inner>
</test>;
var ns = myXml.namespace();
default xml namespace = ns;
this.log(myXml.*::inner);
this.log(myXml.ns::inner);
this.log(myXml.inner);
The first two log statements print "Guys". The third is blank. What's going on? I've specified the default namespace, and it's in fact the exact same thingas I'm using in the second log statement. Why doesn't this work?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 Firefox 3 中,您的代码将按您的预期运行。 也许您遇到了旧版本 Gecko 中发现的错误?
In Firefox 3 your code runs as you expect. Maybe you run into a bug found in older version of Gecko?