Success! Looks like we've fixed this one. According to our records the fix was applied for TOUCH-4126 in a recent build.
  1. #1
    Sencha User
    Join Date
    Aug 2010
    Posts
    6
    Vote Rating
    1
    xanf is on a distinguished road

      0  

    Default [ST 2.1.1] Ext.DomQuery.is do not work with elements outside document

    [ST 2.1.1] Ext.DomQuery.is do not work with elements outside document


    Hi! While researching a bug with my radio buttons inside formpanel not being set correctly on setRecord call, I've figured, that the real problem is that Ext.DomQuery.is do not work for elements outside actual DOM tree.
    Steps to reproduce:
    HTML Code:
    <script>
    var elem = document.createElement('p');
    elem.className = "test"
    alert(Ext.DomQuery.is(elem, ".test")); //expected "true", got "false"
    </script>
    Example on SenchaFiddle: http://www.senchafiddle.com/#vT1xK

    Same code works ok for ExtJS 4, it looks like totally different approach is used for "is" implementation.
    From what I see the problem is with this line
    Code:
    return this.select(q).indexOf(el) !== -1;
    Since we do not pass second parameter to select, select is searching for nodes inside document, which is not the case.

    Following fix solves this problem and should be way more faster:
    HTML Code:
    <script>
        is: function(el, q) {
            var root = el.parentNode;
    
            if (typeof el == "string") {
                el = document.getElementById(el);
            }
    
            if (!root) {
                root = document.createDocumentFragment();
                root.appendChild(el);
            }
     
            return this.select(q, root).indexOf(el) !== -1;
        },
    </script>
    Approach, I've used is:
    - if our element is a child of some other node - we search only this node, otherwise we create a fake element (I'm using documentFragment for that as it is lightweight) - append it there and search this new "fake" root"

  2. #2
    Sencha - Senior Forum Manager mitchellsimoens's Avatar
    Join Date
    Mar 2007
    Location
    Gainesville, FL
    Posts
    36,756
    Vote Rating
    828
    mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute mitchellsimoens has a reputation beyond repute

      0  

    Default


    Thanks for the report! I have opened a bug in our bug tracker.

  3. #3
    Sencha User
    Join Date
    Aug 2010
    Posts
    6
    Vote Rating
    1
    xanf is on a distinguished road

      0  

    Default


    Great. Additionally, I've ran some tests with my code, and found that it's not working when selector is too complex (involves parent elements). I believe this version solves all such problems:
    HTML Code:
    <script>
        is: function(el, q) {
            var root = null;
            if (typeof el == "string"){
                el = document.getElementById(el);
            }
            if (document.contains(el)) {
                root = document;
            } else {
                if (el.parentNode) {
                    root = el.parentNode;
                    while (root.parentNode) {
                        root = root.parentNode;
                    }
                } else {
                    root = document.createDocumentFragment();
                    root.appendChild(el);
                }
            }
            return this.select(q, root).indexOf(el) !== -1;
        },
    </script>

Thread Participants: 1

Tags for this Thread

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