为什么此 E4X 代码不尊重默认命名空间?

发布于 2024-07-11 19:25:56 字数 564 浏览 11 评论 0原文

我正在修改 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”。 第三个是空白。 这是怎么回事? 我已经指定了默认命名空间,它实际上与我在第二条日志语句中使用的完全相同。 为什么这不起作用?

Mozilla 的文档表明这应该可行。

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?

Mozilla's documentation suggests this should work.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌梦深 2024-07-18 19:25:56

在 Firefox 3 中,您的代码将按您的预期运行。 也许您遇到了旧版本 Gecko 中发现的错误?

In Firefox 3 your code runs as you expect. Maybe you run into a bug found in older version of Gecko?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文