diff options
author | mensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2008-11-13 09:49:11 +0000 |
---|---|---|
committer | mensonge <mensonge@b3834d28-1941-0410-a4f8-b48e95affb8f> | 2008-11-13 09:49:11 +0000 |
commit | e44a7e37b6c7b5961adaffc62b9042b8d442938e (patch) | |
tree | 95b67c356e93163467db2451f2b8cce84ed5d582 /includes/js/dojo/tests/_base/query.html | |
parent | a62b9742ee5e28bcec6872d88f50f25b820914f6 (diff) | |
download | semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.gz semanticscuttle-e44a7e37b6c7b5961adaffc62b9042b8d442938e.tar.bz2 |
New feature: basic Ajax suggestion for tags and implementation of Dojo toolkit
git-svn-id: https://semanticscuttle.svn.sourceforge.net/svnroot/semanticscuttle/trunk@151 b3834d28-1941-0410-a4f8-b48e95affb8f
Diffstat (limited to 'includes/js/dojo/tests/_base/query.html')
-rw-r--r-- | includes/js/dojo/tests/_base/query.html | 154 |
1 files changed, 154 insertions, 0 deletions
diff --git a/includes/js/dojo/tests/_base/query.html b/includes/js/dojo/tests/_base/query.html new file mode 100644 index 0000000..5c92221 --- /dev/null +++ b/includes/js/dojo/tests/_base/query.html @@ -0,0 +1,154 @@ +<html> + <head> + <title>testing dojo.query()</title> + <style type="text/css"> + @import "../../resources/dojo.css"; + </style> + <script type="text/javascript" src="../../dojo.js" + djConfig="isDebug: true, debugAtAllCosts: false, noFirebugLite: true"></script> + <script type="text/javascript" src="../../../util/doh/runner.js"></script> + <script type="text/javascript"> + dojo.require("doh.runner"); + dojo.require("dojox.data.dom"); + dojo.addOnLoad(function(){ + doh.register("t", + [ + // basic sanity checks + "doh.is(4, (dojo.query('h3')).length);", + "doh.is(1, (dojo.query('h1:first-child')).length);", + "doh.is(2, (dojo.query('h3:first-child')).length);", + "doh.is(1, (dojo.query('#t')).length);", + "doh.is(1, (dojo.query('#bug')).length);", + "doh.is(4, (dojo.query('#t h3')).length);", + "doh.is(1, (dojo.query('div#t')).length);", + "doh.is(4, (dojo.query('div#t h3')).length);", + "doh.is(0, (dojo.query('span#t')).length);", + "doh.is(1, (dojo.query('#t div > h3')).length);", + "doh.is(2, (dojo.query('.foo')).length);", + "doh.is(1, (dojo.query('.foo.bar')).length);", + "doh.is(2, (dojo.query('.baz')).length);", + "doh.is(3, (dojo.query('#t > h3')).length);", + // syntactic equivalents + "doh.is(12, (dojo.query('#t > *')).length);", + "doh.is(12, (dojo.query('#t >')).length);", + "doh.is(3, (dojo.query('.foo >')).length);", + "doh.is(3, (dojo.query('.foo > *')).length);", + // with a root, by ID + "doh.is(3, (dojo.query('> *', 'container')).length);", + "doh.is(3, (dojo.query('> h3', 't')).length);", + // compound queries + "doh.is(2, (dojo.query('.foo, .bar')).length);", + "doh.is(2, (dojo.query('.foo,.bar')).length);", + // multiple class attribute + "doh.is(1, (dojo.query('.foo.bar')).length);", + "doh.is(2, (dojo.query('.foo')).length);", + "doh.is(2, (dojo.query('.baz')).length);", + // case sensitivity + "doh.is(1, (dojo.query('span.baz')).length);", + "doh.is(1, (dojo.query('sPaN.baz')).length);", + "doh.is(1, (dojo.query('SPAN.baz')).length);", + "doh.is(1, (dojo.query('[class = \"foo bar\"]')).length);", + "doh.is(2, (dojo.query('[foo~=\"bar\"]')).length);", + "doh.is(2, (dojo.query('[ foo ~= \"bar\" ]')).length);", + // "t.is(0, (dojo.query('[ foo ~= \"\\'bar\\'\" ]')).length);", + "doh.is(3, (dojo.query('[foo]')).length);", + "doh.is(1, (dojo.query('[foo$=\"thud\"]')).length);", + "doh.is(1, (dojo.query('[foo$=thud]')).length);", + "doh.is(1, (dojo.query('[foo$=\"thudish\"]')).length);", + "doh.is(1, (dojo.query('#t [foo$=thud]')).length);", + "doh.is(1, (dojo.query('#t [ title $= thud ]')).length);", + "doh.is(0, (dojo.query('#t span[ title $= thud ]')).length);", + "doh.is(1, (dojo.query('[foo|=\"bar\"]')).length);", + "doh.is(1, (dojo.query('[foo|=\"bar-baz\"]')).length);", + "doh.is(0, (dojo.query('[foo|=\"baz\"]')).length);", + "doh.is(dojo.byId('_foo'), dojo.query('.foo:nth-child(2)')[0]);", + "doh.is(dojo.query('style')[0], dojo.query(':nth-child(2)')[0]);", + // descendant selectors + "doh.is(3, dojo.query('>', 'container').length);", + "doh.is(3, dojo.query('> *', 'container').length);", + "doh.is(2, dojo.query('> [qux]', 'container').length);", + "doh.is('child1', dojo.query('> [qux]', 'container')[0].id);", + "doh.is('child3', dojo.query('> [qux]', 'container')[1].id);", + "doh.is(3, dojo.query('>', 'container').length);", + "doh.is(3, dojo.query('> *', 'container').length);", + "doh.is('passed', dojo.query('#bug')[0].value);", + // sibling selectors + "doh.is(1, dojo.query('+', 'container').length);", + "doh.is(3, dojo.query('~', 'container').length);", + "doh.is(1, (dojo.query('.foo + span')).length);", + "doh.is(4, (dojo.query('.foo ~ span')).length);", + "doh.is(1, (dojo.query('#foo ~ *')).length);", + "doh.is(1, (dojo.query('#foo ~')).length);", + // sub-selector parsing + "doh.is(1, dojo.query('#t span.foo:not(span:first-child)').length);", + "doh.is(1, dojo.query('#t span.foo:not(:first-child)').length);", + + // nth-child tests + "doh.is(2, dojo.query('#t > h3:nth-child(odd)').length);", + "doh.is(3, dojo.query('#t h3:nth-child(odd)').length);", + "doh.is(3, dojo.query('#t h3:nth-child(2n+1)').length);", + "doh.is(1, dojo.query('#t h3:nth-child(even)').length);", + "doh.is(1, dojo.query('#t h3:nth-child(2n)').length);", + "doh.is(0, dojo.query('#t h3:nth-child(2n+3)').length);", + "doh.is(2, dojo.query('#t h3:nth-child(1)').length);", + "doh.is(1, dojo.query('#t > h3:nth-child(1)').length);", + "doh.is(3, dojo.query('#t :nth-child(3)').length);", + "doh.is(0, dojo.query('#t > div:nth-child(1)').length);", + "doh.is(7, dojo.query('#t span').length);", + // :empty pseudo-selector + "doh.is(4, dojo.query('#t > span:empty').length);", + "doh.is(6, dojo.query('#t span:empty').length);", + "doh.is(0, dojo.query('h3 span:empty').length);", + "doh.is(1, dojo.query('h3 :not(:empty)').length);", + // escaping of ":" chars inside an ID + function silly_IDs1(){ + doh.t(document.getElementById("silly:id::with:colons")); + doh.is(1, dojo.query("#silly\\:id\\:\\:with\\:colons").length); + }, + function NodeList_identity(){ + var foo = new dojo.NodeList([dojo.byId("container")]); + doh.is(foo, dojo.query(foo)); + }, + function xml(){ + try{ + var doc = dojox.data.dom.createDocument("<ResultSet><Result>One</Result><Result>Two</Result></ResultSet>"); + console.debug(doc); + console.debug(dojox.data.dom.innerXML(doc.documentElement)); + console.debug(dojo.query("Result", doc.documentElement).length); + }catch(e){ console.debug(e); } + } + ] + ); + doh.run(); + }); + </script> + </head> + <body> + <h1>testing dojo.query()</h1> + <div id="t"> + <h3>h3 <span>span</span> endh3 </h3> + <!-- comment to throw things off --> + <div class="foo bar" id="_foo"> + <h3>h3</h3> + <span id="foo"></span> + <span></span> + </div> + <h3>h3</h3> + <h3 class="baz" title="thud">h3</h3> + <span class="foobar baz foo"></span> + <span foo="bar"></span> + <span foo="baz bar thud"></span> + <!-- FIXME: should foo="bar-baz-thud" match? [foo$=thud] ??? --> + <span foo="bar-baz-thudish" id="silly:id::with:colons"></span> + <div id="container"> + <div id="child1" qux="true"></div> + <div id="child2"></div> + <div id="child3" qux="true"></div> + </div> + <div qux="true"></div> + <input id="notbug" name="bug" type="hidden" value="failed" /> + <input id="bug" type="hidden" value="passed" /> + </div> + </body> +</html> + |