1. #1
    Sencha User
    Join Date
    Mar 2007
    Location
    Haarlem, Netherlands
    Posts
    1,243
    Vote Rating
    9
    TommyMaintz will become famous soon enough TommyMaintz will become famous soon enough

      0  

    Default Selector weirdness

    Selector weirdness


    Hey guys,

    I don't know if this is something wrong on my side or just in my brain but i have the following markup:

    Code:
    <div id="websites">
        <div id="website-1">
            
    
    ...</p>
            <div>...</div>
        </div>
        <div id="website-2">
            
    
    ...</p>
            <div>...</div>
        </div>
        <div id="website-3">
            
    
    ...</p>
            <div>...</div>
        </div>
        <div id="website-4">
            
    
    ...</p>
            <div>...</div>
        </div>
        <div id="website-5">
            
    
    ...</p>
            <div>...</div>
        </div>
        <div id="website-6">
            
    
    ...</p>
            <div>...</div>
        </div>
        <div id="website-7">
            
    
    ...</p>
            <div>...</div>
        </div>
        <div id="website-8">
            
    
    ...</p>
            <div>...</div>
        </div>
        <div id="website-9">
            
    
    ...</p>
            <div>...</div>
        </div>
        ...etc
    Now i want to select website 2, 5, 8.

    With cssQuery i was using the following query:
    Code:
    '#websites > div:nth-child(3n+2)'
    This one doesn't work in DomQuery.
    I looked up the definition of nth-child on w3. Here it is:
    The :nth-child(an+b) pseudo-class notation represents an element that has an+b-1 siblings before him...
    This means that the proper selector to do this would be:
    Code:
    '#websites > div:nth-child(3n+2)'
    With DomQuery however its all a bit strange.
    When I use:
    Code:
    '#websites > div:nth-child(odd)'
    it returns website-1, website-3, website-5....

    this is correct

    When i use:
    Code:
    '#websites > div:nth-child(even)'
    it returns website-2, website-4, website-6... etc

    this is correct aswell

    When i use:
    Code:
    '#websites > div:nth-child(2)'
    it returns p, p, p, p, p.... etc

    while it should return website-2 (i think, this is what i dont know for sure...)

    When i use:
    Code:
    '#websites > div:nth-child(3n+2)'
    it returns nothing.

    Can somebody maybe explain to me what i am doing wrong?
    Or is it just strange behaviour of DomQuery.

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

      0  

    Default


    It's not a bug, nth-child(an+b) is not supported. This was a decision I made at some point, but I am open to reconsidering. IMO It's one of those selectors that is not very useful except for css. The performance (it would be slow) and code/complexity to implement it didn't seem worth it.

    As for '#websites > div:nth-child(2)', I created a test page and executed it locally and it worked as expected (1 div element). Are you running the latest DomQuery.js? I've never seen this problem in an older version either, but it makes sense to try the latest code.

Similar Threads

  1. Year selector on calendar widget?
    By kjordan in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 25 Aug 2008, 10:18 PM
  2. Brackets in css selector
    By tof in forum Ext 1.x: Help & Discussion
    Replies: 0
    Last Post: 24 Mar 2007, 3:20 PM
  3. Element and 'the selector should not contain an id'
    By martin in forum Ext 2.x: Help & Discussion
    Replies: 3
    Last Post: 24 Feb 2007, 6:57 AM
  4. Problem with selector/getEls and addClassOnOver
    By davida in forum Community Discussion
    Replies: 1
    Last Post: 18 Dec 2006, 6:52 PM
  5. Editor and Selector GRID
    By ganesh in forum Ext 1.x: Help & Discussion
    Replies: 9
    Last Post: 9 Nov 2006, 12:48 PM

Thread Participants: 1