views:

398

answers:

2

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?

+2  A: 

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.

pope
A: 

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

Eric Miraglia