[kupu-dev] xpath queries on kupu drawers in plone

João Eiras joao.eiras at gmail.com
Thu Jan 25 12:52:32 CET 2007


And another thing: this expression

     //div[@id="kupu-librarydrawer"]

will lookup all div in a document, and for each it'll try to match that id
attribute which is at least a O(N) operation and at most O(N^2). Instead
use the id() function which it the same as using getElementById in the
DOM. Since ids are unique, the implementations store references to the
nodes in some sort of map or hash table for efficieny. So this will always
be much faster:

    id("kupu-librarydrawer")

Just 2 cents :P



Na , Matt <matt at elyt.com> escreveu:

> Plone 2.5.2, Kupu 1.3.9, Firefox 2.0.0.1, Firebug 1.0b9
>
> The symptom is this, if I go to a page edit tab and click the image
> insert button to open the drawers, and then go to the firebug console
> in firefox, I get the following results for xpath queries:
>
>>>> $x('//div[@id="kupu-librarydrawer"]/div')
> []
>>>> $x('//div[@id="kupu-librarydrawer"]/*')
> [h1, div#kupu-searchbox, div.kupu-panels, div.kupu-dialogbuttons]
>
>>>> $x('//div[@id="root"]')
> []
>
>>>> $x('//*[@id="root"]')
> [div#root.kupu-libsource]
>
> The HTML these selectors should locate on are in this fragment:
>
> <div class="kupu-librarydrawer-parent" style="display: block;">
>   <div id="kupu-librarydrawer" class="kupu-drawer kupu-librarydrawer"
> style="display: block;">
>     <h1 style="padding: 0pt; float: left;">Insert Image</h1>
>     <div id="kupu-searchbox" style="text-align: right;">
>       <form onsubmit="return false;">
>       </form>
>     </div>
>     <div class="kupu-panels">
>       <table>
>         <tr class="kupu-panelsrow">
>           <td id="kupu-librariespanel" class="panel">
>             <div id="kupu-librariesitems" class="overflow">
>                <div id="root" class="kupu-libsource"
> onclick="drawertool.current_drawer.selectLibrary('root');"
> title="Home" style="">
>                </div>
>                <div id="current" class="kupu-libsource"
> onclick="drawertool.current_drawer.selectLibrary('current');"
> title="Current folder" style="">
>                </div>
>                <div id="myitems" class="kupu-libsource"
> onclick="drawertool.current_drawer.selectLibrary('myitems');"
> title="My recent items" style="">
>                </div>
>                <div id="recentitems" class="kupu-libsource"
> onclick="drawertool.current_drawer.selectLibrary('recentitems');"
> title="Recent items" style="">
>                </div>
>             </div>
>           </td>
>           <td id="kupu-resourcespanel" class="panel">
>           </td>
>           <td id="kupu-propertiespanel" class="panel">
>           </td>
>         </tr>
>       </table>
>     </div>
>     <div class="kupu-dialogbuttons">
>     </div>
>   </div>
> </div>
>
>
> Either there is something about * I don't understand in xpath
> expressions, or there is something strange going on with xpath that
> firebug uses (which I guess is part of the firefox javascript engine).
> I was wondering if anyone has come across this in their debugging
> sessions, or know why this happens?
>
>
> cheers
> Matt
> _______________________________________________
> kupu-dev mailing list
> kupu-dev at codespeak.net
> http://codespeak.net/mailman/listinfo/kupu-dev




More information about the kupu-dev mailing list