Changeset 1164

Show
Ignore:
Timestamp:
10/17/06 06:35:22 (2 years ago)
Author:
therve@gmail.com
Message:

Arnar's patch for IE, with docs

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • mochikit/branches/selector/MochiKit/Selector.js

    r1160 r1164  
    190190                        break; 
    191191                    case 'enabled': 
    192                         conditions.push('element.disabled === false'); 
     192                        conditions.push('(this.isUIElement(element) && element.disabled === false)'); 
    193193                        break; 
    194194                    case 'disabled': 
    195                         conditions.push('element.disabled'); 
     195                        conditions.push('(this.isUIElement(element) && element.disabled === true)'); 
    196196                        break; 
    197197                    case 'checked': 
    198                         conditions.push('element.checked'); 
     198                        conditions.push('(this.isUIElement(element) && element.checked === true)'); 
    199199                        break; 
    200200                    case 'not': 
     
    276276    }, 
    277277 
     278    /** @id MochiKit.Selector.Selector.prototype.isUIElement */ 
     279    isUIElement: function (element) { 
     280        return findValue(['input', 'button', 'select', 'option', 'textarea', 'object'],  
     281                element.tagName.toLowerCase()) > -1; 
     282    }, 
     283 
    278284    /** @id MochiKit.Selector.Selector.prototype.findElements */ 
    279285    findElements: function (scope, axis) { 
     
    290296                return element.parentNode == scope; 
    291297            } else if (axis == "+") { 
    292                 return element.previousSibling == scope
     298                return element == nextSiblingElement(scope)
    293299            } else if (axis == "~") { 
    294                 while (element.previousSibling) { 
    295                     if (element.previousSibling == scope) { 
     300                var sibling = scope; 
     301                while (sibling = nextSiblingElement(sibling)) { 
     302                    if (element == sibling) { 
    296303                        return true; 
    297304                    } 
    298                     element = element.previousSibling; 
    299305                } 
    300306                return false; 
     
    390396 
    391397function $$() { 
    392     return MochiKit.Selector.findChildElements(currentDocument(), arguments); 
     398    return MochiKit.Selector.findChildElements(MochiKit.DOM.currentDocument(), arguments); 
    393399} 
    394400 
  • mochikit/branches/selector/doc/html/MochiKit/index.html

    r1144 r1164  
    3030<li><a class="mochiref reference" href="LoggingPane.html">MochiKit.LoggingPane</a> - interactive <a class="mochiref reference" href="Logging.html">MochiKit.Logging</a> 
    3131pane</li> 
     32<li><a class="mochiref reference" href="Selector.html">MochiKit.Selector</a> - selecting elements by CSS selector syntax</li> 
    3233<li><a class="mochiref reference" href="Signal.html">MochiKit.Signal</a> - simple universal event handling</li> 
    3334<li><a class="mochiref reference" href="Style.html">MochiKit.Style</a> - painless CSS manipulation API</li> 
  • mochikit/branches/selector/doc/rst/MochiKit/index.rst

    r1043 r1164  
    1818- :mochiref:`MochiKit.LoggingPane` - interactive :mochiref:`MochiKit.Logging` 
    1919  pane 
     20- :mochiref:`MochiKit.Selector` - selecting elements by CSS selector syntax 
    2021- :mochiref:`MochiKit.Signal` - simple universal event handling 
    2122- :mochiref:`MochiKit.Style` - painless CSS manipulation API 
  • mochikit/branches/selector/tests/test_MochiKit-Selector.html

    r1158 r1164  
    1818    <p>Test originally from <a href="http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector" rel="bookmark">this blog entry</a>.</p> 
    1919 
    20     <p>Here are some links in a normal paragraph: <a href="http://www.google.com/" title="Google!">Google</a>, <a href="http://groups.google.com/">Google Groups</a>. This link has <code>class="blog"</code>: <a href="http://diveintomark.org/" class="blog">diveintomark</a></p> 
     20    <p>Here are some links in a normal paragraph: <a href="http://www.google.com/" title="Google!">Google</a>, <a href="http://groups.google.com/">Google Groups</a>. This link has <code>class="blog"</code>: <a href="http://diveintomark.org/" class="blog" fakeattribute="bla">diveintomark</a></p> 
    2121    <div id="foo"> 
    2222    <p>Everything inside the red border is inside a div with <code>id="foo"</code>.</p> 
     
    141141    testExpected(results, expected, "'a[rel=bookmark]' selector"); 
    142142 
     143    expected = ['http://diveintomark.org/']; 
     144    results = $$('a[fakeattribute]'); 
     145    testExpected(results, expected, "'a[fakeattribute]' selector"); 
     146 
     147    /* This doesn't work in IE due to silly DOM implementation 
    143148    expected = ['http://www.google.com/']; 
    144149    results = $$('a[title]'); 
    145150    testExpected(results, expected, "'a[title]' selector"); 
     151    */ 
    146152 
    147153    results = $$('p[lang|="en"]');