[Seaside] Making use of SUElement>>siblings, et al

Lukas Renggli renggli at gmail.com
Sun Jun 3 08:04:28 UTC 2007

> I was playing around with SUElement, and noticed that there doesn't
> actually seem to be a way to use the results of the methods that
> return Enumerables - #siblings, #descendants, etc.

Probably not. I added those methods for completeness, but never used
them myself. Obviously these are not well integrated with the rest of
the framework.

> I know there's SUSelector, which implements #do:, #invoke:arguments:
> and similar, but only applies to a collection that results from
> querying via a selector, not from a collection derived directly from a
> relationship to a specific element.

I was not happy with the solution of SUSelector, never used it myself
and didn't know of anybody else using it.

> Also, this adds duplication, as the methods are essentially
> copy-and-pasted straight from SUSelector - but I'm not sure how best
> to factor them out, and since it's only a local modification, I don't
> want to go messing with the hierarchy anyway.

You are asking for traits and this is not the the only place where we
have duplication in Seaside and Scriptaculous ;-)

In this particular case it would be maybe better to factor out the
functionality to an enumerator object. I am thinking of something

(html element id: 'foo') siblings enumerator
    do: [ :each | ... ]

This would make more sense as it would not clutter SUElement with
enumeration code, as SUElement itself is not enumerable.

> In any case - this allowed me to use the following code:
> (script element id: id) siblings
>         each: [ :each | each element removeClassName: #active ]
> Or, the invoke equivalent:
> (script element id: id) siblings
>         invoke: #removeClassName arguments: (Array with: #active).

Please commit changes to the Seaside repository. And add some tests ;-)


Lukas Renggli

More information about the Seaside mailing list