1. #1
    Ext User
    Join Date
    Apr 2007
    Posts
    4
    Vote Rating
    0
    mauritius is on a distinguished road

      0  

    Default DomQuery: id select with explicit root searches entire doc

    DomQuery: id select with explicit root searches entire doc


    I've been trying to do the following:

    Code:
    result = Ext.DomQuery.select("#foo", bar);
    where bar is some DOM element.

    The search eventually ends up in

    Code:
    function quickId(ns, mode, root, id){
            if(ns == root){
               var d = root.ownerDocument || root;
               return d.getElementById(id);
            }
            ns = getNodes(ns, mode, "*");
            return byId(ns, null, id);
        }
    with BOTH ns and root set to bar. Consequently, the first conditional evaluates to true, and the _entire document_ gets searched for the id in question, not only bar. I don't understand the semantics of ns in this context, so I'm not really sure why this goes wrong, but it should be undisputed that this is not the desired behavior.

    Apart from this bug, thanks for the fast DomQuery.js!

  2. #2
    Ext User Joe's Avatar
    Join Date
    Apr 2007
    Posts
    243
    Vote Rating
    0
    Joe is on a distinguished road

      0  

    Default Maybe by design?

    Maybe by design?


    I'd imaging the team will chime in - but here is a quick note from some Joe programmer.

    In testing - the results you see only happen looking for id (worked fine looking for 'div' for example).

    I am pretty sure Ext caches elements by id. So the fact that is does a document wide search when looking for an ID may be working as designed.

    But the team will be able to say for sure.
    Joseph Francis,
    CoreLan / Meeting Consultants

  3. #3
    Ext User
    Join Date
    Apr 2007
    Posts
    4
    Vote Rating
    0
    mauritius is on a distinguished road

      0  

    Default


    Quote Originally Posted by Joe View Post
    In testing - the results you see only happen looking for id (worked fine looking for 'div' for example).
    yeah, sure, that's also what I'd expect from looking at the code. That quickId function is obviously only used for id queries.

    Quote Originally Posted by Joe View Post
    I am pretty sure Ext caches elements by id. So the fact that is does a document wide search when looking for an ID may be working as designed.
    DomQuery caches the compiled query strings, but not the results. The cached query function is called with the appropriate root object. So the observed behavior is definitely not correct.

  4. #4
    Sencha User jack.slocum's Avatar
    Join Date
    Mar 2007
    Location
    Tampa, FL
    Posts
    6,955
    Vote Rating
    17
    jack.slocum will become famous soon enough jack.slocum will become famous soon enough

      0  

    Default


    The root property does not limit id queries. The only way to limit an id query is to explicitly make it part of the query process:

    Ext.select('#foo #bar');
    Jack Slocum
    Ext JS Founder
    Original author of Ext JS 1, 2 & 3.
    Twitter: @jackslocum
    jack@extjs.com

  5. #5
    Ext User
    Join Date
    Apr 2007
    Posts
    4
    Vote Rating
    0
    mauritius is on a distinguished road

      0  

    Default


    Quote Originally Posted by jack.slocum View Post
    The root property does not limit id queries. The only way to limit an id query is to explicitly make it part of the query process:

    Ext.select('#foo #bar');
    Thanks for that answer. Is there any rationale behind this inconsistency, is it considered a bug/desired behavior, is it going to be fixed?

    The reason I'm asking is twofold. First of all, we used Ext.query as a drop-in replacement for the venerable but slow cssQuery and found that Ext.query breaks our app in all sorts of unexpected places because of this behavior.

    Second, we have a situation where the root is not so easily found via another DOM selector, so the solution you're proposing is not applicable.

  6. #6
    Ext User
    Join Date
    Apr 2007
    Posts
    4
    Vote Rating
    0
    mauritius is on a distinguished road

      0  

    Default


    to (partly) answer myself: One could probably argue that an id is supposed to be unique across the document if one follows the W3C, despite common practice to violate this rule... If this assumption is fulfilled, then this "bug" becomes moot.

Thread Participants: 2

Turkiyenin en sevilen filmlerinin yer aldigi xnxx internet sitemiz olan ve porn sex tarzi bir site olan mobil porno izle sitemiz gercekten dillere destan bir durumda herkesin sevdigi bir site olarak tarihe gececege benziyor. Sitenin en belirgin ozelliklerinden birisi de Turkiyede gercekten kaliteli ve muntazam, duzenli porno izle siteleri olmamasidir. Bu yuzden iste. Ayrica en net goruntu kalitesine sahip adresinde yayinlanmaktadir. Mesela diğer sitelerimizden bahsedecek olursak, en iyi hd porno video arşivine sahip bir siteyiz. "The Best anal porn videos and slut anus, big asses movies set..." hd porno faketaxi