On Sat, 21 Jan 2006, Dan Stowell wrote:
> > PROPOSAL
> > ========
> > LzDatapointer should expose getPosition() to determine position of node's
> > data
> > in array of data.
> >
> > Right now this is available via
> > comp.datapath.xpathQuery("position()")
>
> Which position does the xpathQuery return? There's the zero-based position in
> the parent's childNodes array, and there's also the one-based position.
[enw] position() is an XPath query, so it returns a one-based position.
>
> > I ran across this while optimizing a moderately-sized application for Laszlo
> > Studios. The xpath query isn't getting called enough in my app to make a
> > large
> > difference, but every available ms helps and I'd rather not use undocumented
> > (hence unsupported) calls.
>
> Could this method be added to LzDatapointer, or would that make no sense?
>
> For the record, you can write
>
> comp.datapath.p.getOffset()
>
> or
>
> comp.data.getOffset()
>
> which return zero-based offsets into the childNodes array.
[enw] LzDataElement.getOffset() and __LZgetPosition() function differently in
replicating and non-replicating situations.
In replicating situations, XPath/getPosition() & getOffset() are one apart
because XPath is 1-based and getOffset() is 0-based. When there's no
replication XPath/getPosition() will always return 1.
I'm not sure if the getOffset() return would be sufficient. I lean towards not
making a change if there's a supported way to get similar functionality -
towards as lightweight APIs as possible.
I'll close out the bug with a note about getOffset() unless anybody can provide
a good reason to make this change.
-e
_______________________________________________
Laszlo-user mailing list
[email protected]
http://www.openlaszlo.org/mailman/listinfo/laszlo-user