Changeset 1164
- Timestamp:
- 10/17/06 06:35:22 (2 years ago)
- Files:
-
- mochikit/branches/selector/MochiKit/Selector.js (modified) (4 diffs)
- mochikit/branches/selector/doc/html/MochiKit/Selector.html (added)
- mochikit/branches/selector/doc/html/MochiKit/index.html (modified) (1 diff)
- mochikit/branches/selector/doc/rst/MochiKit/Selector.rst (added)
- mochikit/branches/selector/doc/rst/MochiKit/index.rst (modified) (1 diff)
- mochikit/branches/selector/tests/test_MochiKit-Selector.html (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
mochikit/branches/selector/MochiKit/Selector.js
r1160 r1164 190 190 break; 191 191 case 'enabled': 192 conditions.push(' element.disabled === false');192 conditions.push('(this.isUIElement(element) && element.disabled === false)'); 193 193 break; 194 194 case 'disabled': 195 conditions.push(' element.disabled');195 conditions.push('(this.isUIElement(element) && element.disabled === true)'); 196 196 break; 197 197 case 'checked': 198 conditions.push(' element.checked');198 conditions.push('(this.isUIElement(element) && element.checked === true)'); 199 199 break; 200 200 case 'not': … … 276 276 }, 277 277 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 278 284 /** @id MochiKit.Selector.Selector.prototype.findElements */ 279 285 findElements: function (scope, axis) { … … 290 296 return element.parentNode == scope; 291 297 } else if (axis == "+") { 292 return element .previousSibling == scope;298 return element == nextSiblingElement(scope); 293 299 } 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) { 296 303 return true; 297 304 } 298 element = element.previousSibling;299 305 } 300 306 return false; … … 390 396 391 397 function $$() { 392 return MochiKit.Selector.findChildElements( currentDocument(), arguments);398 return MochiKit.Selector.findChildElements(MochiKit.DOM.currentDocument(), arguments); 393 399 } 394 400 mochikit/branches/selector/doc/html/MochiKit/index.html
r1144 r1164 30 30 <li><a class="mochiref reference" href="LoggingPane.html">MochiKit.LoggingPane</a> - interactive <a class="mochiref reference" href="Logging.html">MochiKit.Logging</a> 31 31 pane</li> 32 <li><a class="mochiref reference" href="Selector.html">MochiKit.Selector</a> - selecting elements by CSS selector syntax</li> 32 33 <li><a class="mochiref reference" href="Signal.html">MochiKit.Signal</a> - simple universal event handling</li> 33 34 <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 18 18 - :mochiref:`MochiKit.LoggingPane` - interactive :mochiref:`MochiKit.Logging` 19 19 pane 20 - :mochiref:`MochiKit.Selector` - selecting elements by CSS selector syntax 20 21 - :mochiref:`MochiKit.Signal` - simple universal event handling 21 22 - :mochiref:`MochiKit.Style` - painless CSS manipulation API mochikit/branches/selector/tests/test_MochiKit-Selector.html
r1158 r1164 18 18 <p>Test originally from <a href="http://simon.incutio.com/archive/2003/03/25/#getElementsBySelector" rel="bookmark">this blog entry</a>.</p> 19 19 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> 21 21 <div id="foo"> 22 22 <p>Everything inside the red border is inside a div with <code>id="foo"</code>.</p> … … 141 141 testExpected(results, expected, "'a[rel=bookmark]' selector"); 142 142 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 143 148 expected = ['http://www.google.com/']; 144 149 results = $$('a[title]'); 145 150 testExpected(results, expected, "'a[title]' selector"); 151 */ 146 152 147 153 results = $$('p[lang|="en"]');
