YUI 3 链接

发布于 2024-07-14 06:41:54 字数 271 浏览 3 评论 0原文

YUI 3 允许你编写
Y.all(".foo").removeClass("bar");

但是它不允许写入
Y.all(".foo").removeClass("bar").set("innerHTML", "baz");

似乎所有“操作”方法总是终止调用链。< br> 这意味着 YUI 3 只提供了 jQuery 一半的链接功能。

有谁知道这是为什么,以及是否有解决方法?

YUI 3 allows you to write
Y.all(".foo").removeClass("bar");

However it does not allow writing
Y.all(".foo").removeClass("bar").set("innerHTML", "baz");

It seems all the "operational" methods always terminate the call chain.
This means YUI 3 only provides half the power of chaining that jQuery provides.

Does anyone know why this is, and if there is a way around it?

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

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

发布评论

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

评论(2

ι不睡觉的鱼゛ 2024-07-21 06:41:54

似乎因为 Y.all 返回一个事物列表,所以在执行removeClass之后,返回一个对象数组,而不是 Node 对象。

但是,如果您使用一切,

Y.get("#foo").removeClass("bar").set("innerHTML", "baz");

那么一切都会按您的预期工作,因为它是在单个对象上工作的。

也许您应该将此告诉 YUI 人员并了解报告错误。 也许这是预期的行为,但我认为你想做的事情更强大。

It seems that because Y.all returns a list of things, after doing removeClass, an array of objects gets returned, not the Node object.

If, however, you use

Y.get("#foo").removeClass("bar").set("innerHTML", "baz");

everything works as you expect, because it's working on a single object.

Perhaps you should tell this to the YUI folks and see about reporting a bug. Maybe this is expected behavior, but I think what you want to do is way more powerful.

烟柳画桥 2024-07-21 06:41:54

奥伦,

显然你已经意识到了这一点,但为了以后偶然发现它的人完成这个线程 -

http://tech.groups.yahoo.com/group/ydn-javascript/message/45375

简而言之,这是一个错误(由 Oren 打开),正在跟踪此处:

http://yuilibrary.com/projects/yui3/ticket/2525997

-埃里克

Oren,

Obviously you're aware of this already, but to complete this thread for those who stumble upon it later --

http://tech.groups.yahoo.com/group/ydn-javascript/message/45375

In short, this is a bug (opened by Oren) and it's being tracked here:

http://yuilibrary.com/projects/yui3/ticket/2525997

-Eric

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