├── speed ├── frameworks │ ├── native.js │ └── mootools-slick.js ├── slickspeed │ ├── logo.png │ ├── footer.html │ ├── instructions.txt │ ├── index.php │ ├── selectors.list.yahoo.css │ ├── selectors.list.css │ ├── selectors.list.org.css │ ├── selectors.list.mine.css │ ├── selectors.list.sly.css │ ├── config.ini │ ├── selectors.list.extended.css │ ├── header.php │ ├── selectors.list.simple.css │ ├── style.css │ └── system │ │ ├── index.php │ │ ├── slickspeed.js │ │ └── template.php ├── subtleslickspeed │ ├── README.mdown │ ├── lib │ │ ├── subtlesandbox_strict.html │ │ ├── print.css │ │ ├── ie.css │ │ ├── own_tests │ │ │ └── report_test.html │ │ ├── subtleslickspeed.reports.js │ │ ├── table_report.css │ │ └── subtlesandbox.js │ └── tests │ │ └── selectors │ │ ├── template.html │ │ └── tests.js └── jslitmus │ ├── JSLitmusHelpers.js │ ├── select.html │ ├── bench_catch.html │ ├── label_break-vs-fn_return.html │ ├── bench_parse.js │ ├── method_vs_propfn.html │ ├── label_string-vs-var.html │ ├── get_attribute.html │ ├── closedNodes.html │ ├── nodeListtoArray.html │ ├── bench_uidOf.html │ ├── select_class.html │ ├── demo.html │ ├── bench_match.js │ ├── bench_select.js │ ├── select_id.html │ ├── bench_select2.js │ ├── selectXML.html │ ├── results.html │ └── bench_parse.html ├── .gitignore ├── SlickSpec ├── assets │ ├── moobugger │ │ ├── images │ │ │ ├── max.png │ │ │ ├── min.png │ │ │ ├── close.png │ │ │ ├── error.png │ │ │ ├── icon.png │ │ │ ├── info.png │ │ │ ├── lick.png │ │ │ ├── time.png │ │ │ ├── mootools.png │ │ │ ├── warning.png │ │ │ ├── group-open.png │ │ │ └── group-close.png │ │ ├── debugger.html │ │ ├── bookmarklet.html │ │ ├── debugger.css │ │ └── test.html │ ├── simple_request.js │ ├── getgetter.js │ ├── ie.css │ └── JSSpec.css ├── specs │ ├── specs_slick_docs.js │ ├── isxml.specs.js │ ├── slick_xml_specs.js │ ├── syntax.js │ ├── specs-select_nth-child.js │ ├── specs-select_exhaustive.js │ └── slick_match_specs.js ├── mocks │ ├── xmlmock1.xml │ ├── template_xml.html │ ├── GoogleClosure-query_test.html │ ├── dojo-query_test.html │ ├── MooTools_Logo.svg │ ├── yui-query_test.html │ ├── Prototype-query_test.html │ └── template_test.html ├── slick.html ├── bootstrap │ ├── nwmatcher.slickspec.js │ ├── yui.slickspec.js │ ├── moo12.slickspec.js │ ├── slick.slickspec.js │ └── sizzle.slickspec.js ├── parse.html ├── user-specs │ └── pseudos.html ├── match.html ├── framework_Slick.html ├── specrunner_browser.html ├── SlickSpec_ownSpecs.html └── select.html ├── package.yml └── README.md /speed/frameworks/native.js: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | slick.tmproj 2 | slick.js -------------------------------------------------------------------------------- /speed/slickspeed/logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subtleGradient/slick/HEAD/speed/slickspeed/logo.png -------------------------------------------------------------------------------- /speed/frameworks/mootools-slick.js: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subtleGradient/slick/HEAD/speed/frameworks/mootools-slick.js -------------------------------------------------------------------------------- /SlickSpec/assets/moobugger/images/max.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subtleGradient/slick/HEAD/SlickSpec/assets/moobugger/images/max.png -------------------------------------------------------------------------------- /SlickSpec/assets/moobugger/images/min.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subtleGradient/slick/HEAD/SlickSpec/assets/moobugger/images/min.png -------------------------------------------------------------------------------- /SlickSpec/assets/moobugger/images/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subtleGradient/slick/HEAD/SlickSpec/assets/moobugger/images/close.png -------------------------------------------------------------------------------- /SlickSpec/assets/moobugger/images/error.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subtleGradient/slick/HEAD/SlickSpec/assets/moobugger/images/error.png -------------------------------------------------------------------------------- /SlickSpec/assets/moobugger/images/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subtleGradient/slick/HEAD/SlickSpec/assets/moobugger/images/icon.png -------------------------------------------------------------------------------- /SlickSpec/assets/moobugger/images/info.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subtleGradient/slick/HEAD/SlickSpec/assets/moobugger/images/info.png -------------------------------------------------------------------------------- /SlickSpec/assets/moobugger/images/lick.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subtleGradient/slick/HEAD/SlickSpec/assets/moobugger/images/lick.png -------------------------------------------------------------------------------- /SlickSpec/assets/moobugger/images/time.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subtleGradient/slick/HEAD/SlickSpec/assets/moobugger/images/time.png -------------------------------------------------------------------------------- /SlickSpec/assets/moobugger/images/mootools.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subtleGradient/slick/HEAD/SlickSpec/assets/moobugger/images/mootools.png -------------------------------------------------------------------------------- /SlickSpec/assets/moobugger/images/warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subtleGradient/slick/HEAD/SlickSpec/assets/moobugger/images/warning.png -------------------------------------------------------------------------------- /SlickSpec/assets/moobugger/images/group-open.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subtleGradient/slick/HEAD/SlickSpec/assets/moobugger/images/group-open.png -------------------------------------------------------------------------------- /SlickSpec/assets/moobugger/images/group-close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/subtleGradient/slick/HEAD/SlickSpec/assets/moobugger/images/group-close.png -------------------------------------------------------------------------------- /SlickSpec/specs/specs_slick_docs.js: -------------------------------------------------------------------------------- 1 | function specsSlickDocs(){ 2 | Describe('MultiDocs',function(){ 3 | 4 | // it['should exist'] = TODO; 5 | 6 | }); 7 | 8 | }; 9 | -------------------------------------------------------------------------------- /speed/subtleslickspeed/README.mdown: -------------------------------------------------------------------------------- 1 | SubtleSlickSpeed 2 | ================ 3 | 4 | A/B testing framework with much awesome 5 | --------------------------------------- 6 | 7 | -------------------------------------------------------------------------------- /speed/slickspeed/footer.html: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /speed/slickspeed/instructions.txt: -------------------------------------------------------------------------------- 1 | 1) edit config.ini and fill in your framework list. 2 | 2) edit selectors.list and edit your selectors list. 3 | 3) edit style.css, header.html and footer.html if you wish. 4 | 4) edit template.html if you want to change the selectors html file. It DOES NOT accept the full document, just elements. -------------------------------------------------------------------------------- /speed/jslitmus/JSLitmusHelpers.js: -------------------------------------------------------------------------------- 1 | var describe = function(description, specs){ 2 | var test; 3 | for (var name in specs) { 4 | test = JSLitmus.test(description+': '+name, specs[name]); 5 | // JSLitmus._queueTest(test); 6 | } 7 | }; 8 | 9 | function runSpecs(){ 10 | // setTimeout(function(){ 11 | // JSLitmus.runAll(); 12 | // }, 1000); 13 | }; 14 | -------------------------------------------------------------------------------- /package.yml: -------------------------------------------------------------------------------- 1 | name: "Slick" 2 | 3 | web: "[mootools.net](http://mootools.net)" 4 | 5 | description: "Slick, the most awesome CSS Parser and Finder" 6 | 7 | license: "[MIT License](http://mootools.net/license.txt)" 8 | 9 | copyright: "© [MooTools](http://mootools.net)" 10 | 11 | authors: 12 | - Thomas Aylott 13 | - Valerio Proietti 14 | - Fabio M Costa 15 | - Jan Kassens 16 | 17 | sources: 18 | - "Source/Slick.Parser.js" 19 | - "Source/Slick.Finder.js" 20 | -------------------------------------------------------------------------------- /speed/slickspeed/index.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /SlickSpec/mocks/xmlmock1.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | tes 4 | 5 | html 6 | 7 | 8 | tes 9 | 10 | 11 | 12 | 13 | 14 | text 15 | 16 | -------------------------------------------------------------------------------- /speed/slickspeed/selectors.list.yahoo.css: -------------------------------------------------------------------------------- 1 | #page 2 | #masthead 3 | #mastheadhd 4 | .mastheadbd 5 | .first 6 | .on 7 | div 8 | li 9 | a 10 | div.mastheadbd 11 | li.first 12 | li.on 13 | #page div 14 | #dtba span 15 | div#page 16 | div#masthead 17 | #page .mastheadbd 18 | #page .first 19 | .outer_search_container .search_container 20 | .searchbox_container .inputtext 21 | * 22 | #page div.mastheadbd 23 | #page li.first 24 | input[name=p] 25 | a[name=marketplace] 26 | .outer_search_container div 27 | .searchbox_container span 28 | [name=p] 29 | [name=marketplace] 30 | ul li 31 | form input 32 | #page #e2econtent 33 | #page #e2e -------------------------------------------------------------------------------- /speed/slickspeed/selectors.list.css: -------------------------------------------------------------------------------- 1 | body 2 | div 3 | body div 4 | div p 5 | div > p 6 | div + p 7 | div ~ p 8 | div[class^=exa][class$=mple] 9 | div p a 10 | div, p, a 11 | .note 12 | div.example 13 | ul .tocline2 14 | div.example, div.note 15 | #title 16 | h1#title 17 | div #title 18 | ul.toc li.tocline2 19 | ul.toc > li.tocline2 20 | h1#title + div > p 21 | h1[id]:contains(Selectors) 22 | a[href][lang][class] 23 | div[class] 24 | div[class=example] 25 | div[class^=exa] 26 | div[class$=mple] 27 | div[class*=e] 28 | div[class|=dialog] 29 | div[class!=made_up] 30 | div[class~=example] 31 | div:not(.example) 32 | p:contains(selectors) 33 | p:nth-child(even) 34 | p:nth-child(2n) 35 | p:nth-child(odd) 36 | p:nth-child(2n+1) 37 | p:nth-child(n) 38 | p:only-child 39 | p:last-child 40 | p:first-child -------------------------------------------------------------------------------- /speed/jslitmus/select.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Benchmarks 6 | 7 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /SlickSpec/slick.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Slick Specs 5 | 6 | 7 | 8 | 9 |
10 | 11 | 12 |

SlickSpec public release 1

13 |
14 |

Slick.js Specific

15 | 20 |
21 | 22 | 23 |
24 | 25 | 26 | -------------------------------------------------------------------------------- /speed/subtleslickspeed/lib/subtlesandbox_strict.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | SubtleSandbox Strict 7 | 8 | 9 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /speed/slickspeed/selectors.list.org.css: -------------------------------------------------------------------------------- 1 | .a1 .a2 .a3 .a4 .a5 .a6 2 | .a2 .a4 .a6 3 | .a1>.a2>.a3>.a4>.a5>.a6 4 | body #title 5 | body h1#title 6 | body div#title 7 | body div #title 8 | body blockquote #title 9 | body div 10 | body div p 11 | body p 12 | body div > p 13 | body div + p 14 | body div ~ p 15 | body div[class^=exa][class$=mple] 16 | body div p a 17 | body div, p, a 18 | body .note 19 | body div.example 20 | body ul .tocline2 21 | body div.example, div.note 22 | body ul.toc li.tocline2 23 | body ul.toc > li.tocline2 24 | body h1#title + div > p 25 | body h1[id]:contains(Selectors) 26 | body a[href][lang][class] 27 | body div[class] 28 | body div[class=example] 29 | body div[class^=exa] 30 | body div[class$=mple] 31 | body div[class*=e] 32 | body div[class|=dialog] 33 | body div[class!=made_up] 34 | body div[class~=example] 35 | body div:not(.example) 36 | body p:contains(markup) 37 | body p:contains(selectors) -------------------------------------------------------------------------------- /SlickSpec/specs/isxml.specs.js: -------------------------------------------------------------------------------- 1 | function specsIsXML(){ 2 | 3 | 4 | new Mock(/\b(xml|svg|xhtml)\b/i, function(specs,context){ 5 | var SELECT = (context.SELECT || global.SELECT); 6 | Describe('is XML',function(){ 7 | it['should be XML'] = function(){ 8 | value_of( context.document.nodeType ).should_be(9); 9 | value_of( context.document ).should_not_be( global.document ); 10 | value_of(context.isXML(context.document)).should_be_true(); 11 | }; 12 | }); 13 | }); 14 | 15 | new Mock(/\b(html)\b/i, function(specs,context){ 16 | var SELECT = (context.SELECT || global.SELECT); 17 | Describe('is not XML',function(){ 18 | it['should not be XML'] = function(){ 19 | value_of( context.document.nodeType ).should_be(9); 20 | value_of( context.document ).should_not_be( global.document ); 21 | value_of(context.isXML(context.document)).should_be_false(); 22 | }; 23 | }); 24 | }); 25 | 26 | 27 | }; 28 | -------------------------------------------------------------------------------- /speed/subtleslickspeed/tests/selectors/template.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Template 7 | 8 | 9 | 10 | 11 |

Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

12 | 13 | 14 | 15 | -------------------------------------------------------------------------------- /speed/slickspeed/selectors.list.mine.css: -------------------------------------------------------------------------------- 1 | .a1 2 | .a1 .a2 3 | b.a1 4 | b.a1, i.a2 5 | .a1 .a2 .a3 .a4 .a5 .a6 6 | .a2 .a4 .a6 7 | .a1 > .a2 > .a3 8 | #title 9 | h1#title 10 | div #title 11 | blockquote #title 12 | div 13 | p 14 | div > p 15 | div + p 16 | div ~ p 17 | div[class^=exa][class$=mple] 18 | div p a 19 | div, p, a 20 | div p 21 | p em 22 | p a[href] 23 | h2 a[name] 24 | .note 25 | .example 26 | .dtd-example 27 | div.example 28 | ul .tocline2 29 | div.example, div.note 30 | dl dd.vcard 31 | ul.toc li.tocline2 32 | ul.toc > li.tocline2 33 | h1#title ~ p > a 34 | p ~ div > a 35 | h1[id]:contains(Selectors) 36 | a[href][lang][class] 37 | div[class] 38 | div[class=example] 39 | div[class^=exa] 40 | div[class$=mple] 41 | div[class*=e] 42 | div[class|=dialog] 43 | div[class!=made_up] 44 | div[class~=example] 45 | a[href^="#"] 46 | a[href^=#] 47 | a[href^='#'] 48 | a:first-child 49 | a:last-child 50 | div:not(.example) 51 | div:not(:contains("Example")) 52 | a:not(div[class]) 53 | p:empty 54 | p:contains(selectors) -------------------------------------------------------------------------------- /speed/slickspeed/selectors.list.sly.css: -------------------------------------------------------------------------------- 1 | .a1 2 | .a1 .a2 3 | div.a1 div.a2 4 | .a1 .a2 .a3 .a4 .a5 .a6 5 | .a2 .a4 .a6 6 | .a1 > .a2 > .a3 7 | #title 8 | h1#title 9 | div#title 10 | div #title 11 | blockquote #title 12 | div 13 | div p 14 | p 15 | div > p 16 | div + p 17 | div ~ p 18 | div[class^=exa][class$=mple] 19 | div p a 20 | div, p, a 21 | p em 22 | p a[href] 23 | h2 a[name] 24 | .note 25 | .example 26 | .dtd-example 27 | div.example 28 | ul .tocline2 29 | div.example, div.note 30 | dl dd.vcard 31 | ul.toc li.tocline2 32 | ul.toc > li.tocline2 33 | h1#title ~ p + a 34 | p ~ div > a 35 | h1[id]:contains(Selectors) 36 | a[href][lang][class] 37 | div[class] 38 | div[class=example] 39 | div[class^=exa] 40 | div[class$=mple] 41 | div[class*=e] 42 | div[class|=dialog] 43 | div[class!=made_up] 44 | div[class~=example] 45 | a[href^="#"] 46 | a[href^=#] 47 | a[href^='#'] 48 | a:first-child 49 | a:last-child 50 | div:not(.example) 51 | div:not(:contains("Example")) 52 | a:not(div[class]) 53 | p:contains(markup) 54 | p:contains(selectors) -------------------------------------------------------------------------------- /SlickSpec/assets/moobugger/debugger.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | debugger 6 | 7 | 8 | 9 | 10 | 11 |
12 |
13 | 14 | 15 | 16 | 17 | 18 |
19 |
20 |
21 | 22 |
23 |
24 | 25 | -------------------------------------------------------------------------------- /SlickSpec/bootstrap/nwmatcher.slickspec.js: -------------------------------------------------------------------------------- 1 | function setupMethods(specs, window){ 2 | global.cannotDisableQSA = true; 3 | 4 | window.SELECT = function(context, selector, append){ 5 | return (window.NW || global.NW).Dom.select(selector, context, append); 6 | }; 7 | window.MATCH = function(context, selector){ 8 | return (window.NW || global.NW).Dom.match(context, selector); 9 | }; 10 | window.isXML = TODO; 11 | } 12 | 13 | function verifySetupMethods(specs, window){ 14 | Describe('Verify Setup',function(){ 15 | it['should define SELECT'] = function(){ 16 | value_of( typeof window.SELECT ).should_be('function'); 17 | value_of( window.SELECT(window.document, '*').length ).should_not_be(0); 18 | }; 19 | it['should define MATCH'] = function(){ 20 | value_of( typeof window.MATCH ).should_be('function'); 21 | value_of( window.MATCH(window.document.documentElement, '*') ).should_be_true(); 22 | }; 23 | it['should define isXML'] = function(){ 24 | value_of( typeof window.isXML ).should_be('function'); 25 | }; 26 | }); 27 | }; 28 | 29 | setupMethods({},this); 30 | new Mock('',setupMethods); 31 | 32 | verifySetupMethods({},this); 33 | new Mock('',verifySetupMethods); 34 | -------------------------------------------------------------------------------- /SlickSpec/assets/simple_request.js: -------------------------------------------------------------------------------- 1 | var SimpleRequest = (function(){ 2 | 3 | function SimpleRequest(){ 4 | this.initialize(); 5 | }; 6 | SimpleRequest.prototype = { 7 | 8 | initialize: function(){ 9 | this.xhr = this.createXHR(); 10 | }, 11 | 12 | createXHR: function(){ 13 | // return ('XMLHttpRequest' in window)? new XMLHttpRequest(): new ActiveXObject('MSXML2.XMLHTTP'); 14 | return ('XMLHttpRequest' in window)? new XMLHttpRequest(): new ActiveXObject('Microsoft.XMLHTTP'); 15 | }, 16 | 17 | stateChange: function(fn){ 18 | if(this.xhr.readyState == 4 && this.xhr.status == 200){ 19 | fn.apply(this, [this.xhr.responseText, this.getXML()]); 20 | } 21 | }, 22 | 23 | getXML: function(){ 24 | if (this.xhr.responseXML && this.xhr.responseXML.documentElement) 25 | return this.xhr.responseXML; 26 | return parseXML(this.xhr.responseText); 27 | }, 28 | 29 | send: function(url, fn){ 30 | var self = this; 31 | this.xhr.onreadystatechange = function(){ self.stateChange(fn); }; 32 | this.xhr.open('get', url + '?n=' + (new Date()).getTime(), true); 33 | this.xhr.send(null); 34 | } 35 | 36 | }; 37 | 38 | return SimpleRequest; 39 | })(); 40 | -------------------------------------------------------------------------------- /SlickSpec/assets/moobugger/bookmarklet.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | bugger 9 | 10 | 33 | 34 | 35 | 36 | 37 | 38 | 39 |
40 |

The MooBugger.

41 |

moobugger - bookmark it!

42 |
43 | 44 | 45 | 46 | -------------------------------------------------------------------------------- /speed/jslitmus/bench_catch.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | Demo Test Suite 9 | 10 | 11 | 44 | 45 | 46 |

Compare various ways of aborting the rest of the operations

47 |
48 | 49 | 50 | -------------------------------------------------------------------------------- /SlickSpec/specs/slick_xml_specs.js: -------------------------------------------------------------------------------- 1 | function specsAssetsTemplateXML(specs,context){ 2 | 3 | Describe('SELECT Selector Engine on XML file',function(){ 4 | 5 | function makeSlickTestSearch(selector, count, disableQSA) { 6 | return function(){ 7 | context.SELECT.disableQSA = !!disableQSA; 8 | value_of( context.SELECT(context.document, selector).length ).should_be( count ); 9 | delete context.SELECT.disableQSA; 10 | }; 11 | } 12 | function it_should_find(count,selector){ 13 | if (global.document.querySelectorAll && !global.cannotDisableQSA) 14 | specs['should find '+count+' `'+selector+'` with QSA' ] = makeSlickTestSearch(selector, count, false); 15 | specs['should find '+count+' `'+selector + (!global.cannotDisableQSA ? '` without QSA' : '') ] = makeSlickTestSearch(selector, count, true); 16 | }; 17 | 18 | it_should_find(1, 'HTML'); 19 | it_should_find(1, '#id_idnode'); 20 | it_should_find(1, '[id=id_idnode]'); 21 | it_should_find(3, '.class_classNode'); 22 | it_should_find(3, '[class=class_classNode]'); 23 | it_should_find(0, '[className=class_classNode]'); 24 | it_should_find(3, 'camelCasedTag'); 25 | it_should_find(1, '#node[style=border]'); 26 | it_should_find(1, '[href^=http://]'); 27 | 28 | }); 29 | 30 | }; 31 | -------------------------------------------------------------------------------- /SlickSpec/mocks/template_xml.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | template xhtml as html 7 | 8 | 9 | 10 | 11 | 12 | 13 | 31 | 32 | 33 | 36 | 37 | 38 | -------------------------------------------------------------------------------- /SlickSpec/specs/syntax.js: -------------------------------------------------------------------------------- 1 | var TAGS = 'normal UPCASE escaped\\,character ǝpoɔıun'.split(' '); 2 | 3 | var IDS = "normal escaped\\,character ǝpoɔıun with-dash with_underscore 123number silly\\:id\\:\\:with\\:colons".split(' '); 4 | 5 | var CLASSES = "normal escaped\\,character ǝpoɔıun 瀡 with-dash with_underscore 123number MiXeDcAsE".split(' '); 6 | 7 | var ATTRIB_OPERATORS = '= != *= ^= $= ~= |='.split(' '); 8 | 9 | var ATTRIB_KEYS = '\ 10 | normal,\ 11 | spaced,\ 12 | spaced ,\ 13 | escaped\\]character,\ 14 | ǝpoɔıun,\ 15 | with-dash,\ 16 | with_underscore,\ 17 | 123number,\ 18 | '.split(','); 19 | 20 | var ATTRIB_VALUES = '\ 21 | normal,\ 22 | ǝpoɔıun,\ 23 | "double quote",\ 24 | \'single quote\',\ 25 | "double\\"escaped",\ 26 | \'single\\\'escaped\',\ 27 | spaced,\ 28 | spaced ,\ 29 | "spaced",\ 30 | \'spaced\',\ 31 | "spaced" ,\ 32 | \'spaced\' ,\ 33 | parens(),\ 34 | curly{},\ 35 | "quoted parens()",\ 36 | "quoted curly{}",\ 37 | "quoted square[]",\ 38 | '.split(','); 39 | // TODO: add "square[]" to ATTRIB_VALUES for prototype support 40 | 41 | var PSEUDO_KEYS = 'normal escaped\\,character ǝpoɔıun with-dash with_underscore'.split(' '); 42 | 43 | var PSEUDO_VALUES = 'normal,ǝpoɔıun, spaced,"double quote",\'single quote\',"double\\"escaped",\'single\\\'escaped\',curly{},square[],"quoted parens()","quoted curly{}","quoted square[]"'.split(',');; 44 | 45 | var COMBINATORS = (" >+~" + "`!@$%^&={}\\;body p code {*white-space:normal;} 23 | hr {margin:-8px auto 11px;} 24 | .clearfix, .container {display:inline-block;} 25 | * html .clearfix, * html .container {height:1%;} 26 | fieldset {padding-top:0;} -------------------------------------------------------------------------------- /speed/slickspeed/config.ini: -------------------------------------------------------------------------------- 1 | ; [MooTools 1.2.4] 2 | ; file = "mootools.js" 3 | ; function = "$$" 4 | ; 5 | ; [MooTools 1.2.1 E] 6 | ; initialize = "function $$E(s){return document.getElements(s,true);};" 7 | ; file = "mootools.js?E" 8 | ; function = "$$E" 9 | 10 | [Slick last version] 11 | file = "../../slick.js" 12 | function = "Slick.search(%2$s, %1$s)" 13 | 14 | [Slick pre-alpha] 15 | file = "slick.js" 16 | function = "Slick.search(%2$s, %1$s)" 17 | 18 | [Sly] 19 | file = "sly.js" 20 | function = "Sly.search" 21 | 22 | ; [Prototype 1.6.0.3] 23 | ; file = "prototype.js" 24 | ; function = "Selector.findChildElements(%2$s, [%1$s])" 25 | 26 | ;[NWMatcher] 27 | ; file = "nwmatcher.js" 28 | ; initialize = "NW.Dom.setCache(false); (function(){})" 29 | ; function = "NW.Dom.select" 30 | 31 | [Dojo 1.3.0] 32 | file = "dojo.js" 33 | function = "dojo.query" 34 | ; 35 | [Sizzle] 36 | file = "sizzle.js" 37 | function = "Sizzle" 38 | 39 | ; [DOMAss] 40 | ; file = "domass.js" 41 | ; function = "\$" 42 | ; 43 | ; [querySelectorAll] 44 | ; file = "native.js" 45 | ; function = "document.querySelectorAll" 46 | 47 | ; just add a framework here following the conventions to add another framework. 48 | ; the function parameter is to choose the right css selector function name 49 | ; the include parameter is to include the right javascript file 50 | 51 | ; [myframework] 52 | ; file = "myFramework.js" 53 | ; function = "getElements" 54 | -------------------------------------------------------------------------------- /speed/slickspeed/selectors.list.extended.css: -------------------------------------------------------------------------------- 1 | * 2 | A 3 | [foo] 4 | [foo="bar"] 5 | [foo~="bar"] 6 | [hreflang|="en"] 7 | [foo^="bar"] 8 | [foo$="bar"] 9 | [foo*="bar"] 10 | :first-child 11 | :root 12 | :nth-child(n) 13 | :nth-last-child(n) 14 | :nth-of-type(n) 15 | :nth-last-of-type(n) 16 | :last-child 17 | :first-of-type 18 | :last-of-type 19 | :only-child 20 | :only-of-type 21 | :empty 22 | :link 23 | :visited 24 | :active 25 | :hover 26 | :focus 27 | :lang(fr) 28 | :target 29 | :disabled 30 | :enabled 31 | :checked 32 | ::first-line 33 | ::first-letter 34 | ::before 35 | ::after 36 | ::selection 37 | .warning 38 | #myid 39 | #myid 40 | * B 41 | * > B 42 | * + B 43 | * ~ B 44 | :not(B) 45 | :not(*) 46 | :not([foo]) 47 | :not([foo="bar"]) 48 | :not([foo~="bar"]) 49 | :not([hreflang|="en"]) 50 | :not([foo^="bar"]) 51 | :not([foo$="bar"]) 52 | :not([foo*="bar"]) 53 | :not(:first-child) 54 | :not(:root) 55 | :not(:nth-child(n)) 56 | :not(:nth-last-child(n)) 57 | :not(:nth-of-type(n)) 58 | :not(:nth-last-of-type(n)) 59 | :not(:last-child) 60 | :not(:first-of-type) 61 | :not(:last-of-type) 62 | :not(:only-child) 63 | :not(:only-of-type) 64 | :not(:empty) 65 | :not(:link) 66 | :not(:visited) 67 | :not(:active) 68 | :not(:hover) 69 | :not(:focus) 70 | :not(:lang(fr)) 71 | :not(:target) 72 | :not(:disabled) 73 | :not(:enabled) 74 | :not(:checked) 75 | :not(::first-line) 76 | :not(::first-letter) 77 | :not(::before) 78 | :not(::after) 79 | :not(::selection) 80 | :not(.warning) 81 | :not(#myid) -------------------------------------------------------------------------------- /SlickSpec/parse.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Slick Parse :: SlickSpec 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 29 | 30 | 31 | 32 |

SlickSpec

33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /SlickSpec/user-specs/pseudos.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | template xhtml as html 8 | 9 | 10 | 11 | 22 | 23 | 24 |
Should become green onclick
25 |
Shouldn't become green onclick
26 | Should become green onclick 27 | 28 | 29 | 44 | 45 | -------------------------------------------------------------------------------- /speed/slickspeed/header.php: -------------------------------------------------------------------------------- 1 |

SlickSpeed

2 | 3 |
4 |

5 | 6 | NEW! 7 | Check 8 | 13 | selector list against 14 | 19 | case 20 | (Refresh/Copy Link) 21 |

22 |
23 | 24 |

speed/validity selectors test for frameworks.

25 |

26 | Every framework runs in his own iFrame, thus no conflicts can happen. Tests are run selector by selector, with an interval to prevent the browser from freeezing. 27 | Tests are run in a neutral environment (against a local copy of this document), no library or framework is included in the main javascript test, to avoid favoritism. 28 |

-------------------------------------------------------------------------------- /speed/slickspeed/selectors.list.simple.css: -------------------------------------------------------------------------------- 1 | #title 2 | h1#title 3 | div#title 4 | div #title 5 | a #title 6 | .company 7 | .copyright 8 | .described 9 | .dtd-example 10 | .example 11 | .figure 12 | .fn 13 | .head 14 | .index-inst 15 | .inner 16 | .meaning 17 | .note 18 | .profile 19 | .refs 20 | .selectorsReview 21 | .subtoc 22 | .title 23 | .toc 24 | .toc .tocline2 25 | .tocline2, .tocline3, .tocline4 26 | .tprofile 27 | .url 28 | .vcard 29 | .wrapper 30 | a 31 | a.inner 32 | .url.fn 33 | a.url.fn 34 | a[href^="http://"] 35 | a[href^=#] 36 | a[href=#] 37 | abbr 38 | abbr[title] 39 | abbr[title^="CSS"] 40 | acronym 41 | b 42 | br 43 | cite 44 | code 45 | dd 46 | dd.vcard 47 | dfn 48 | div 49 | div.example 50 | div.figure 51 | div.head 52 | div.note 53 | div.profile 54 | div.subtoc 55 | div.wrapper 56 | dl dt 57 | dl.refs 58 | dl dt 59 | dt 60 | em 61 | h2, h3, h4, h5 62 | hr 63 | .nest.a1 .flatInNest 64 | i.nest.a1 b.flatInNest 65 | img 66 | li 67 | li.tocline2 68 | li.tocline3 69 | li.tocline4 70 | ol 71 | p 72 | p.copyright 73 | p.note 74 | pre 75 | pre.dtd-example 76 | span 77 | span.company 78 | span.fn 79 | span.index-inst 80 | span.note 81 | strong 82 | sup 83 | table 84 | table.selectorsReview 85 | table.tprofile 86 | table .origin 87 | table .pattern 88 | table td.origin 89 | table td.pattern 90 | tbody 91 | td 92 | td.described 93 | td.meaning 94 | td.pattern, td.origin 95 | th 96 | th.described 97 | th.meaning 98 | table th.origin 99 | table th.pattern 100 | th.title 101 | thead 102 | tr 103 | ul 104 | ul.toc 105 | var -------------------------------------------------------------------------------- /SlickSpec/bootstrap/yui.slickspec.js: -------------------------------------------------------------------------------- 1 | function setupMethods(specs, window){ 2 | global.cannotDisableQSA = true; 3 | 4 | var YAHOO_util_Selector = (window.YAHOO || global.YAHOO).util.Selector; 5 | 6 | window.SELECT = function(context, selector, append){ 7 | return YAHOO_util_Selector.query(selector, context); 8 | }; 9 | window.SELECT1 = function(context, selector){ 10 | console.log('SELECT1', selector, context, true); 11 | return YAHOO_util_Selector.query(selector, context, true); 12 | }; 13 | window.MATCH = function(context, selector){ 14 | return YAHOO_util_Selector.test(context, selector); 15 | }; 16 | window.isXML = TODO; 17 | } 18 | 19 | function verifySetupMethods(specs, window){ 20 | Describe('Verify Setup',function(){ 21 | it['should define SELECT'] = function(){ 22 | value_of( typeof window.SELECT ).should_be('function'); 23 | value_of( window.SELECT(window.document, '*').length ).should_not_be(0); 24 | }; 25 | it['should define SELECT1'] = function(){ 26 | value_of( typeof window.SELECT1 ).should_be('function'); 27 | value_of( window.SELECT1(window.document, '*').length ).should_not_be(0); 28 | }; 29 | it['should define MATCH'] = function(){ 30 | value_of( typeof window.MATCH ).should_be('function'); 31 | value_of( window.MATCH(window.document.documentElement, '*') ).should_be_true(); 32 | }; 33 | it['should define isXML'] = function(){ 34 | value_of( typeof window.isXML ).should_be('function'); 35 | }; 36 | }); 37 | }; 38 | 39 | setupMethods({},this); 40 | new Mock('',setupMethods); 41 | 42 | verifySetupMethods({},this); 43 | new Mock('',verifySetupMethods); 44 | -------------------------------------------------------------------------------- /speed/jslitmus/label_break-vs-fn_return.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | Demo Test Suite 9 | 10 | 11 | 60 | 61 | 62 |

Compare various ways of aborting the rest of the operations

63 |
64 | 65 | 66 | -------------------------------------------------------------------------------- /speed/subtleslickspeed/lib/own_tests/report_test.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | report_test.html 7 | 8 | 11 | 12 | 60 | 61 | 62 | 63 | 64 | 65 | -------------------------------------------------------------------------------- /speed/jslitmus/bench_parse.js: -------------------------------------------------------------------------------- 1 | // -*- Mode: JavaScript; tab-width: 4; -*- 2 | var local = {}; 3 | local.collectionToArray = function(node){ 4 | return Array.prototype.slice.call(node); 5 | }; 6 | try{ 7 | local.collectionToArray(root.childNodes); 8 | } 9 | catch(e){ 10 | local.collectionToArray = function(node){ 11 | if (node instanceof Array) return node; 12 | var i = node.length, array = new Array(i); 13 | while (i--) array[i] = node[i]; 14 | return array; 15 | }; 16 | } 17 | 18 | 19 | function benchmarkParser(specs,context){ 20 | var selectors = global.selectors; 21 | if (global.disableQSA) { 22 | try{ 23 | context.document.querySelector = null; 24 | context.Element.prototype.querySelectorAll = null; 25 | context.document.querySelector = null; 26 | context.Element.prototype.querySelector = null; 27 | }catch(e){} 28 | } 29 | 30 | global.SlickLast.debug = function(error){ 31 | throw error; 32 | }; 33 | global.SlickThis.debug = function(error){ 34 | throw error; 35 | }; 36 | 37 | it['THIS.parse'] = _benchmarkParser(global.SlickThis.parse, context, selectors); 38 | it['LAST.parse'] = _benchmarkParser(global.SlickLast.parse, context, selectors); 39 | } 40 | 41 | function _benchmarkParser(PARSE,context,selectors,before,after){ 42 | function __benchmarkParser(count){ 43 | var document = context.document; 44 | var i, ii, node, l; 45 | var elements = PARSE('*'); 46 | before = before || function(){}; 47 | after = after || function(){}; 48 | before(context); 49 | var results = {}; 50 | 51 | while(count--){ 52 | for (ii=0; ii < selectors.length; ii++) if (selectors[ii]){ 53 | 54 | for (var property in PARSE.cache) { PARSE.cache[property] = null; } 55 | for (var property in PARSE.reverseCache) { PARSE.cache[property] = null; } 56 | try{ 57 | results[selectors[ii]] = PARSE(selectors[ii]).length; 58 | }catch(error){ 59 | results[selectors[ii]] = error; 60 | } 61 | 62 | } 63 | } 64 | after(context); 65 | return results; 66 | } 67 | return __benchmarkParser; 68 | }; 69 | -------------------------------------------------------------------------------- /SlickSpec/assets/getgetter.js: -------------------------------------------------------------------------------- 1 | // -*- Mode: JavaScript; tab-width: 4; -*- 2 | 3 | (function(){ 4 | 5 | window.scripts_to_get = window.scripts_to_get || parent.scripts_to_get || window.location.search.match(/\bscript=(.*?\.js)/gi) || []; 6 | 7 | for (var i=0, scriptsrc; scriptsrc = scripts_to_get[i]; i++){ 8 | 9 | scripts_to_get[i] = scriptsrc = decodeURIComponent(scriptsrc.replace(/^(&?script=)+/,'')); 10 | 11 | scriptsrc.replace(/^(?!=http|\/)/,'../'); 12 | 13 | var written; 14 | if (document.write){ 15 | try { 16 | document.write('<\/script>'); 17 | written = true; 18 | } catch(e){ 19 | written = false; 20 | } 21 | } 22 | 23 | if (!written && document.documentElement.nodeName == 'HTML'){ 24 | var script = document.createElement('script'); 25 | script.setAttribute('src', scriptsrc); 26 | script.setAttribute('type', 'text/javascript'); 27 | document.documentElement.appendChild(script); 28 | } 29 | 30 | // else evalRemote(scriptsrc); 31 | 32 | if (/\bbootstrap\b/.test(scriptsrc)) scripts_to_get.splice(i,1); 33 | 34 | } 35 | 36 | this.frameworkName = (scripts_to_get[0] || '').replace(/^.*\//,''); 37 | 38 | // function evalRemote(url){ 39 | // if (!(/^(\/|http:)/).test(url) && /\bmocks\b/.test(document.location.href)) url = '../' + url; 40 | // 41 | // var code = getResource(url); 42 | // 43 | // try { 44 | // globalEval(code); 45 | // } catch(e){ 46 | // try{console.log(e);}catch(e){}; 47 | // } 48 | // }; 49 | // 50 | // function getResource(url) { 51 | // if (!(XMLHttpRequest || ActiveXObject)) return false; 52 | // request = (XMLHttpRequest) ? new XMLHttpRequest() : new ActiveXObject("Microsoft.XMLHTTP"); 53 | // if (!request) return false; 54 | // request.open("GET", url + '?' + Math.random().toString(32), false); 55 | // // try { 56 | // request.send(null); 57 | // // } catch(e){} 58 | // 59 | // if (request.status != 200) return false; 60 | // return request.responseText; 61 | // } 62 | // 63 | })(); 64 | -------------------------------------------------------------------------------- /SlickSpec/assets/ie.css: -------------------------------------------------------------------------------- 1 | /* 2 | curl -s http://tripledoubleyou.subtlegradient.com/c/blueprint/ie.css #*/ 3 | /* ----------------------------------------------------------------------- 4 | 5 | 6 | Blueprint CSS Framework 0.9 7 | http://blueprintcss.org 8 | 9 | * Copyright (c) 2007-Present. See LICENSE for more info. 10 | * See README for instructions on how to use Blueprint. 11 | * For credits and origins, see AUTHORS. 12 | * This is a compressed file. See the sources in the 'src' directory. 13 | 14 | ----------------------------------------------------------------------- */ 15 | 16 | /* ie.css */ 17 | body {text-align:center;} 18 | .container {text-align:left;} 19 | * html .column, * html div.span-1, * html div.span-2, * html div.span-3, * html div.span-4, * html div.span-5, * html div.span-6, * html div.span-7, * html div.span-8, * html div.span-9, * html div.span-10, * html div.span-11, * html div.span-12, * html div.span-13, * html div.span-14, * html div.span-15, * html div.span-16, * html div.span-17, * html div.span-18, * html div.span-19, * html div.span-20, * html div.span-21, * html div.span-22, * html div.span-23, * html div.span-24 {display:inline;overflow-x:hidden;} 20 | * html legend {margin:0px -8px 16px 0;padding:0;} 21 | sup {vertical-align:text-top;} 22 | sub {vertical-align:text-bottom;} 23 | html>body p code {*white-space:normal;} 24 | hr {margin:-8px auto 11px;} 25 | img {-ms-interpolation-mode:bicubic;} 26 | .clearfix, .container {display:inline-block;} 27 | * html .clearfix, * html .container {height:1%;} 28 | fieldset {padding-top:0;} 29 | textarea {overflow:auto;} 30 | input.text, input.title, textarea {background-color:#fff;border:1px solid #bbb;} 31 | input.text:focus, input.title:focus {border-color:#666;} 32 | input.text, input.title, textarea, select {margin:0.5em 0;} 33 | input.checkbox, input.radio {position:relative;top:.25em;} 34 | form.inline div, form.inline p {vertical-align:middle;} 35 | form.inline label {position:relative;top:-0.25em;} 36 | form.inline input.checkbox, form.inline input.radio, form.inline input.button, form.inline button {margin:0.5em 0;} 37 | button, input.button {position:relative;top:0.25em;} 38 | -------------------------------------------------------------------------------- /SlickSpec/bootstrap/moo12.slickspec.js: -------------------------------------------------------------------------------- 1 | function setupMethods(specs, window){ 2 | var Element = window.Element || global.Element; 3 | global.disableNegNth = true; 4 | global.cannotDisableQSA = true; 5 | 6 | window.SELECT = function(context, selector, append){ 7 | return Element.getElements(context, selector); 8 | }; 9 | window.SELECT1 = function(context, selector){ 10 | return Element.getElement(context, selector); 11 | }; 12 | window.MATCH = function(context, selector){ 13 | return Element.match(context, selector); 14 | }; 15 | // window.isXML = function(document){ 16 | // return Slick.isXML(document); 17 | // }; 18 | // window.PARSE = function(selector){ 19 | // return Slick.parse(selector); 20 | // }; 21 | } 22 | 23 | function verifySetupMethods(specs, window){ 24 | Describe('Verify Setup',function(){ 25 | it['should define SELECT'] = function(){ 26 | value_of( typeof window.SELECT ).should_be('function'); 27 | value_of( window.SELECT(window.document, '*').length ).should_not_be(0); 28 | }; 29 | it['should define MATCH'] = function(){ 30 | value_of( typeof window.MATCH ).should_be('function'); 31 | value_of( window.MATCH(window.document.documentElement, '*') ).should_be_true(); 32 | }; 33 | // it['should define isXML'] = function(){ 34 | // value_of( typeof window.isXML ).should_be('function'); 35 | // value_of( typeof window.isXML(window.document) ).should_be('boolean'); 36 | // }; 37 | }); 38 | }; 39 | function verifySetupContext(specs, context){ 40 | Describe('Verify Context',function(){ 41 | 42 | it['should set the context properly'] = function(){ 43 | value_of(context.document).should_not_be_undefined(); 44 | value_of(context.document.nodeType).should_be(9); 45 | 46 | var title = context.document.getElementsByTagName('title'); 47 | for (var i=0, l=title.length; i < l; i++) 48 | if (title[i].firstChild) 49 | value_of(title[i].firstChild.nodeValue).should_not_match(404); 50 | 51 | }; 52 | 53 | }); 54 | }; 55 | 56 | setupMethods({},this); 57 | new Mock('',setupMethods); 58 | 59 | verifySetupMethods({},this); 60 | new Mock('',verifySetupMethods); 61 | new Mock('',verifySetupContext); 62 | -------------------------------------------------------------------------------- /speed/jslitmus/method_vs_propfn.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Benchmark prototype Method vs Object Property Fn 7 | 8 | 9 | 104 | 105 | 106 |

Benchmark prototype Method vs Object Property Fn

107 |
108 | 109 | 110 | -------------------------------------------------------------------------------- /SlickSpec/mocks/GoogleClosure-query_test.html: -------------------------------------------------------------------------------- 1 | 2 | 15 | 16 | 21 | 22 | 23 | Closure Unit Tests - goog.dom 24 | 25 | 26 | 27 |

testing goog.dom.query()

28 |
29 |

h3 span endh3

30 | 31 |
32 |

h3

33 | 34 | 35 |
36 |

h3

37 |

h3

38 | 39 | 40 | 41 | 42 | 43 |
44 |
45 |
46 |
47 |
48 |
49 | 50 | 51 |
52 | 53 |
54 | 55 | 56 | 57 | 58 | 59 | 60 |
61 | 62 | 63 |
64 |
65 |
66 |
67 |
68 |
69 |
70 | 71 | 72 | 73 | -------------------------------------------------------------------------------- /speed/subtleslickspeed/lib/subtleslickspeed.reports.js: -------------------------------------------------------------------------------- 1 | /* 2 | SubtleSlickSpeed.Report 3 | Copyright 2009 Thomas Aylott (subtleGradient.com) 4 | LICENSE: MIT 5 | */ 6 | SubtleSlickSpeed.Report = (function(){ 7 | 8 | function Report(tests){ 9 | // console.log('Report()', {tests:tests}); 10 | this.tests = {}; 11 | var self = this; 12 | self.updateOne.timeouts = {}; 13 | this.updateOneBound = function(test){ 14 | if (self.updateOne.timeouts[test.id]) clearTimeout(self.updateOne.timeouts[test.id]); 15 | self.updateOne.timeouts[test.id] = setTimeout(function(){ 16 | self.updateOne.call(self, test); 17 | // self.fireEvent('update'); 18 | },100); 19 | }; 20 | this.addTests = function(tests){ 21 | Object.each(tests, connectTest, self); 22 | return self; 23 | }; 24 | 25 | if (tests) this.addTests(tests); 26 | }; 27 | Report.prototype = { 28 | 29 | // element, 30 | 31 | // tests:{}, 32 | 33 | // addTests: function(){}, 34 | 35 | buildWrapperElement: function(){ 36 | // console.log('Report#buildWrapperElement'); 37 | var dad = document.createElement('ul'); 38 | document.body.appendChild(dad); 39 | return dad 40 | }, 41 | 42 | buildOne: function(test){ 43 | // console.log('Report#buildOne'); 44 | var one = document.createElement('li'); 45 | one.innerHTML = pp({ 46 | id : test.id, 47 | fn : test.fn, 48 | // runs : test.runs, 49 | data : test.getData() 50 | }); 51 | return one; 52 | }, 53 | 54 | toElement: function(){ 55 | // console.log('Report#toElement'); 56 | if (this.element) return this.element; 57 | return this.element = this.buildWrapperElement(); 58 | }, 59 | 60 | // Update a single test passively 61 | updateOne: function(test){ 62 | // console.log('Report#updateOne', { test:test }); 63 | var dad = this.toElement(); 64 | var elNew = this.buildOne(test); 65 | var el = elements[test.id]; 66 | if (el && el.parentNode && elNew) { 67 | el.parentNode.replaceChild(elNew, el); 68 | } else { 69 | if (elNew) dad.appendChild(elNew); 70 | } 71 | elements[test.id] = elNew; 72 | return this; 73 | } 74 | }; 75 | 76 | var elements = {}; 77 | function connectTest(test, id){ 78 | // console.log('Report##connectTest', { test:test }); 79 | test.id = test.id || id; 80 | this.tests[test.id] = test; 81 | 82 | if (!test || !test.addEvent) return; 83 | test.addEvent('complete', this.updateOneBound); 84 | }; 85 | 86 | return Report; 87 | })(); 88 | -------------------------------------------------------------------------------- /SlickSpec/bootstrap/slick.slickspec.js: -------------------------------------------------------------------------------- 1 | function setupMethods(specs, window){ 2 | var Slick = window.Slick || global.Slick; 3 | 4 | window.SELECT = function(context, selector, append){ 5 | return Slick.search(context, selector, append); 6 | }; 7 | window.SELECT1 = function(context, selector){ 8 | return Slick.find(context, selector); 9 | }; 10 | window.MATCH = function(context, selector, root){ 11 | return Slick.match(context, selector, root); 12 | }; 13 | window.isXML = function(document){ 14 | return Slick.isXML(document); 15 | }; 16 | window.PARSE = function(selector){ 17 | return Slick.parse(selector); 18 | }; 19 | } 20 | 21 | function verifySetupMethods(specs, window){ 22 | Describe('Verify Setup',function(){ 23 | it['should define SELECT'] = function(){ 24 | value_of( typeof window.SELECT ).should_be('function'); 25 | value_of( window.SELECT(window.document, '*').length ).should_not_be(0); 26 | }; 27 | it['should define SELECT1'] = function(){ 28 | value_of( typeof window.SELECT1 ).should_be('function'); 29 | value_of( window.SELECT1(window.document, '*') ).should_not_be_null(); 30 | }; 31 | it['should define MATCH'] = function(){ 32 | value_of( typeof window.MATCH ).should_be('function'); 33 | value_of( window.MATCH(window.document.documentElement, '*') ).should_be_true(); 34 | }; 35 | it['should define isXML'] = function(){ 36 | value_of( typeof window.isXML ).should_be('function'); 37 | value_of( typeof window.isXML(window.document) ).should_be('boolean'); 38 | }; 39 | it['should define PARSE'] = function(){ 40 | value_of( typeof window.PARSE ).should_be('function'); 41 | value_of( typeof window.PARSE('*') ).should_be('object'); 42 | value_of( window.PARSE('*').expressions.length ).should_be(1); 43 | value_of( window.PARSE('*').expressions[0].length ).should_be(1); 44 | }; 45 | }); 46 | }; 47 | function verifySetupContext(specs, context){ 48 | Describe('Verify Context',function(){ 49 | 50 | it['should set the context properly'] = function(){ 51 | value_of(context.document).should_not_be_undefined(); 52 | value_of(context.document.nodeType).should_be(9); 53 | 54 | var title = context.document.getElementsByTagName('title'); 55 | for (var i=0, l=title.length; i < l; i++) 56 | if (title[i].firstChild) 57 | value_of(title[i].firstChild.nodeValue).should_not_match(404); 58 | 59 | }; 60 | 61 | }); 62 | }; 63 | 64 | setupMethods({},this); 65 | new Mock('',setupMethods); 66 | 67 | verifySetupMethods({},this); 68 | new Mock('',verifySetupMethods); 69 | new Mock('',verifySetupContext); 70 | -------------------------------------------------------------------------------- /SlickSpec/specs/specs-select_nth-child.js: -------------------------------------------------------------------------------- 1 | function specsSelectNthChild(){ 2 | 3 | Describe('nth-child',function(specs,context){ 4 | 5 | var parent; 6 | function should_select(selector, items){ 7 | var result = context.SELECT(parent, selector); 8 | value_of(result.length).should_be(items.length); 9 | for (var i = 0; i < result.length; i++){ 10 | value_of(result[i].innerHTML).should_be('' + items[i]); 11 | } 12 | } 13 | 14 | specs.before_all = function(){ 15 | parent = context.document.createElement('div'); 16 | for (var i = 1, el; i <= 10; i++){ 17 | el = document.createElement('div'); 18 | el.appendChild(document.createTextNode(i)); 19 | parent.appendChild(el); 20 | }; 21 | }; 22 | specs.after_all = function(){ 23 | parent = null; 24 | }; 25 | 26 | it['should match by index'] = function(){ 27 | should_select(':nth-child(0)', []); 28 | should_select(':nth-child(1)', [1]); 29 | should_select(':nth-child(10)', [10]); 30 | should_select(':nth-child(11)', []); 31 | }; 32 | if (!global.disableNegNth) 33 | it['should match by index with negative'] = function(){ 34 | should_select(':nth-child(-1)', []); 35 | }; 36 | it['should match even'] = function(){ 37 | should_select(':nth-child(even)', [2, 4, 6, 8, 10]); 38 | }; 39 | it['should match odd'] = function(){ 40 | should_select(':nth-child(odd)', [1, 3, 5, 7, 9]); 41 | }; 42 | it['should select no elements'] = function(){ 43 | should_select(':nth-child(-n)', []); 44 | should_select(':nth-child(4n+100)', []); 45 | }; 46 | it['should select all elements'] = function(){ 47 | should_select(':nth-child(n)', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); 48 | should_select(':nth-child(-n+100)', [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]); 49 | }; 50 | it['should skip a number of first elements'] = function(){ 51 | should_select(':nth-child(2n+5)', [5, 7, 9]); 52 | should_select(':nth-child(n+8)', [8, 9, 10]); 53 | }; 54 | if (!global.disableNegNth) 55 | it['should skip a number of last elements'] = function(){ 56 | should_select(':nth-child(-2n+5)', [1, 3, 5]); 57 | should_select(':nth-child(-4n+2)', [2]); 58 | should_select(':nth-child(-n+2)', [1, 2]); 59 | }; 60 | it['should work with multiple nth-child selectors'] = function(){ 61 | should_select(':nth-child(2n):nth-child(3n+1)', [4, 10]); 62 | should_select(':nth-child(n+3):nth-child(-n+5)', [3, 4, 5]); 63 | }; 64 | it['should work with both nth-child and nth-last-child'] = function(){ 65 | should_select(':nth-child(odd):nth-last-child(odd)', []); 66 | }; 67 | }); 68 | 69 | }; 70 | -------------------------------------------------------------------------------- /speed/jslitmus/label_string-vs-var.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | Demo Test Suite 9 | 10 | 11 | 89 | 90 | 91 |

Compare various ways of aborting the rest of the operations

92 |
93 | 94 | 95 | -------------------------------------------------------------------------------- /SlickSpec/match.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Slick Features :: SlickSpec 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 31 | 32 |

SlickSpec

33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 50 | 51 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /speed/jslitmus/get_attribute.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | :: SlickSpec 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | -------------------------------------------------------------------------------- /SlickSpec/bootstrap/sizzle.slickspec.js: -------------------------------------------------------------------------------- 1 | function setupMethods(specs, window){ 2 | global.cannotDisableQSA = true; 3 | 4 | var jQuery = window.jQuery || global.jQuery || function(){}; 5 | var Sizzle = window.Sizzle || global.Sizzle || jQuery() && function(selector, context, append, seed){ 6 | if (seed) return Array.prototype.slice.call(jQuery(seed).filter(selector).get()); 7 | return Array.prototype.slice.call(jQuery(append || []).add(selector, context).get()); 8 | }; 9 | 10 | var isXML = jQuery.isXMLDoc || function(elem){ 11 | return elem.nodeType === 9 && elem.documentElement.nodeName !== "HTML" || 12 | !!elem.ownerDocument && isXML( elem.ownerDocument ); 13 | }; 14 | 15 | window.SELECT = function(context, selector, append){ 16 | return Sizzle(selector, context, append); 17 | }; 18 | window.SELECT1 = function(context, selector){ 19 | return Sizzle(selector + ':first', context)[0]; 20 | }; 21 | window.MATCH = function(context, selector, root){ 22 | return !!Sizzle(selector, null, null, [context]).length; 23 | }; 24 | window.isXML = function(document){ 25 | return isXML(document); 26 | }; 27 | } 28 | 29 | function verifySetupMethods(specs, window){ 30 | Describe('Verify Setup',function(){ 31 | it['should define SELECT'] = function(){ 32 | value_of( typeof window.SELECT ).should_be('function'); 33 | value_of( window.SELECT(window.document, '*').length ).should_not_be(0); 34 | }; 35 | it['should define SELECT1'] = function(){ 36 | value_of( typeof window.SELECT1 ).should_be('function'); 37 | value_of( window.SELECT1(window.document, '*') ).should_not_be_null(); 38 | }; 39 | it['should define MATCH'] = function(){ 40 | value_of( typeof window.MATCH ).should_be('function'); 41 | value_of( window.MATCH(window.document.documentElement, '*') ).should_be_true(); 42 | }; 43 | it['should define isXML'] = function(){ 44 | value_of( typeof window.isXML ).should_be('function'); 45 | value_of( typeof window.isXML(window.document) ).should_be('boolean'); 46 | }; 47 | }); 48 | }; 49 | function verifySetupContext(specs, context){ 50 | Describe('Verify Context',function(){ 51 | 52 | it['should set the context properly'] = function(){ 53 | value_of(context.document).should_not_be_undefined(); 54 | value_of(context.document.nodeType).should_be(9); 55 | 56 | var title = context.document.getElementsByTagName('title'); 57 | for (var i=0, l=title.length; i < l; i++) 58 | if (title[i].firstChild) 59 | value_of(title[i].firstChild.nodeValue).should_not_match(404); 60 | 61 | }; 62 | 63 | }); 64 | }; 65 | 66 | setupMethods({},this); 67 | new Mock('',setupMethods); 68 | 69 | verifySetupMethods({},this); 70 | new Mock('',verifySetupMethods); 71 | new Mock('',verifySetupContext); 72 | -------------------------------------------------------------------------------- /SlickSpec/framework_Slick.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Slick Features :: SlickSpec 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 33 | 34 |

SlickSpec

35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 52 | 53 | 59 | 60 | 61 | -------------------------------------------------------------------------------- /SlickSpec/specrunner_browser.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Browser Bugs (some should fail) :: SlickSpec 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 35 | 36 |

SlickSpec

37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 53 | 54 | 60 | 68 | 69 | 70 | -------------------------------------------------------------------------------- /speed/jslitmus/closedNodes.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | :: SlickSpec 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /SlickSpec/mocks/dojo-query_test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | testing dojo.query() 4 | 7 | 9 | 12 | 13 | 14 | 28 | 29 | 30 |

testing dojo.query()

31 |
32 |

h3 span endh3

33 | 34 |
35 |

h3

36 | 37 | 38 |
39 |

h3

40 |

h3

41 | 42 | 43 | 44 | 45 | 46 |
47 |
48 |
49 |
50 |
51 |
52 | 53 | 54 |
55 |
56 | 57 | 58 | 59 | 60 | 61 | 62 |
63 | 68 | 69 | 70 |
71 |
72 |

one

73 |
74 |

two

75 |
76 |
77 |
78 | 79 | 80 | -------------------------------------------------------------------------------- /speed/jslitmus/nodeListtoArray.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | :: SlickSpec 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | -------------------------------------------------------------------------------- /SlickSpec/mocks/MooTools_Logo.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 25 | -------------------------------------------------------------------------------- /speed/jslitmus/bench_uidOf.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | Demo Test Suite 9 | 10 | 11 | 117 | 118 | 119 |
120 | 121 | 122 | -------------------------------------------------------------------------------- /speed/jslitmus/select_class.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | :: SlickSpec 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 91 | 92 | 93 | -------------------------------------------------------------------------------- /speed/slickspeed/style.css: -------------------------------------------------------------------------------- 1 | body { 2 | font: 11px "Lucida Grande", "Trebuchet MS", Verdana, sans-serif; 3 | color: #41464D; 4 | margin: 0; 5 | padding: 0; 6 | background: #F3F1F1; 7 | } 8 | 9 | /*main rules*/ 10 | 11 | a:link, a:visited { 12 | color: #528CE0; 13 | } 14 | 15 | a:hover, a:active { 16 | color: #C65F5E; 17 | } 18 | 19 | p { 20 | font-size: 13px; 21 | margin: 0; 22 | padding: 3px 0; 23 | } 24 | 25 | iframe { 26 | height: 1px; 27 | width: 1px; 28 | visibility: hidden; 29 | } 30 | 31 | span.clr { 32 | display: block; 33 | clear: both; 34 | } 35 | 36 | /*header*/ 37 | 38 | h1 { 39 | font-family: Georgia; 40 | margin: 0; 41 | padding: 0; 42 | background: url(logo.png) no-repeat top left; 43 | height: 69px; 44 | width: 280px; 45 | } 46 | 47 | h1 span { 48 | display: none; 49 | } 50 | 51 | h2 { 52 | margin: 0; 53 | padding: 10px 0; 54 | font-size: 15px; 55 | } 56 | 57 | #container { 58 | padding: 30px; 59 | } 60 | 61 | /*controls*/ 62 | 63 | #controls a:link, #controls a:visited { 64 | display: block; 65 | float: right; 66 | background: #D0C8C8; 67 | padding: 7px 10px; 68 | font-size: 13px; 69 | font-weight: bold; 70 | margin-left: 10px; 71 | text-align: center; 72 | text-decoration: none; 73 | border: 3px solid #fff; 74 | color: #41464D; 75 | text-shadow: 2px 2px 1px #B9ACAC; 76 | } 77 | 78 | #controls a:hover, #controls a:active { 79 | text-shadow: none; 80 | background: #F3F1F1; 81 | color: #528CE0; 82 | } 83 | 84 | /*table*/ 85 | 86 | table { 87 | border-collapse: collapse; 88 | width: 100%; 89 | min-width: 800px; 90 | margin: 0; 91 | padding: 0; 92 | table-layout: fixed; 93 | } 94 | 95 | #legend td { 96 | padding: 15px; 97 | } 98 | 99 | td, th { 100 | background: #C8CBD0; 101 | padding: 5px 8px; 102 | margin: 0; 103 | width: 150px; 104 | font-weight: bold; 105 | border: 3px solid #fff; 106 | } 107 | 108 | th { 109 | font-weight: bold; 110 | background: #D0C8C8; 111 | color: #8A7575; 112 | } 113 | 114 | th.framework { 115 | font-size: 15px; 116 | text-shadow: 2px 2px 1px #B9ACAC; 117 | } 118 | 119 | td.test, td.empty, th { 120 | text-align: right; 121 | } 122 | 123 | td.normal { 124 | color: #636A75; 125 | } 126 | 127 | td.mismatch { 128 | color: #AD7520; 129 | } 130 | 131 | td.good { 132 | color: #657528; 133 | background: #CFE773; 134 | } 135 | 136 | td.bad { 137 | color: #B33F3F; 138 | background: #EE9A9A; 139 | } 140 | 141 | td.exception { 142 | color: #F3F1F1; 143 | background: #41464D; 144 | } 145 | 146 | span.exception { 147 | color: #DBEAF0; 148 | text-decoration: underline; 149 | cursor: help; 150 | } 151 | 152 | td.zero { 153 | color: #F3F1F1; 154 | background: #41464D; 155 | } 156 | 157 | th.selector { 158 | background: #D2E0E6; 159 | color: #528CE0; 160 | text-align: left; 161 | } 162 | 163 | th.score-title, th.selectors-title { 164 | text-align: left; 165 | font-size: 12px; 166 | width: 180px; 167 | } 168 | 169 | td.score { 170 | color: #8A7575; 171 | background: #D0C8C8; 172 | text-align: center; 173 | font-size: 12px; 174 | } 175 | 176 | td.mismatch { 177 | background: #E8C896; 178 | } 179 | 180 | td b { 181 | float:left; 182 | display:inline; 183 | width:49%; 184 | font-weight:inherit; 185 | } 186 | 187 | /*page footer*/ 188 | 189 | div#footer { 190 | padding: 20px 0; 191 | } 192 | 193 | div#footer p { 194 | font-size: 11px; 195 | color: #B9ACAC; 196 | } 197 | 198 | -------------------------------------------------------------------------------- /speed/jslitmus/demo.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | Demo Test Suite 9 | 10 | 11 | 91 | 92 | 93 | 94 |

A simple demo showing how JSLitmus can be used to test the performance of some core JavaScript features. View source to see fully commented code.

95 |
96 | 97 | 98 | -------------------------------------------------------------------------------- /SlickSpec/mocks/yui-query_test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | YUI Selector Test Suite 5 | 6 | 7 | 8 | 9 |
10 |

lorem ipsum

11 |

lorem ipsum

12 |

lorem ipsum

13 |

div lorem

14 |

last child

15 |
16 | 17 |
18 |
child of demo2
19 |
20 | 21 |
22 | 23 | 28 |
29 |
    30 |
  1. foo
  2. 31 |
  3. foo
  4. 32 |
  5. foo
  6. 33 |
  7. foo
  8. 34 |
  9. foo
  10. 35 |
  11. foo
  12. 36 |
  13. foo
  14. 37 |
  15. foo
  16. 38 |
  17. foo
  18. 39 |
  19. foo
  20. 40 |
41 |
42 |
43 | span 44 |
first div
45 | span 46 |
second div
47 |
third div
48 |
fourth div
49 | span 50 |
51 | foo 52 |
53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 |
62 | 63 |
64 | 65 | 66 |
67 | 68 |
69 |

H3 - Title

70 |

lorem ipsum dolor sit link

71 |
72 | 73 |
74 |
contains "' & ]
75 |
76 | 77 | 78 |
79 |
Window size
80 |
dd1
81 |
Document size
82 |
dd2
83 | 84 |
85 |
custom attribute
86 | 87 | 88 | -------------------------------------------------------------------------------- /SlickSpec/specs/specs-select_exhaustive.js: -------------------------------------------------------------------------------- 1 | function specsSelectorExhaustive(specs,context){ 2 | 3 | Describe('CLASS',function(specs,context){ 4 | 5 | specs.before_each = function(){ 6 | testNodeOrphaned = context.document.createElement('div'); 7 | testNode = context.document.createElement('div'); 8 | bodyElement = context.document.getElementsByTagName('body')[0]; 9 | bodyElement = bodyElement || context.document.documentElement; 10 | bodyElement.appendChild(testNode); 11 | }; 12 | specs.after_each = function(){ 13 | testNode && testNode.parentNode && testNode.parentNode.removeChild(testNode); 14 | testNode = null; 15 | testNodeOrphaned = null; 16 | }; 17 | 18 | var it_should_select_classes = function(CLASSES){ 19 | 20 | var testName = 'Should select element with class "'+ CLASSES.join(' ') +'"'; 21 | var className = CLASSES.join(' '); 22 | if (className.indexOf('\\')+1) className += ' ' + CLASSES.join(' ').replace('\\',''); 23 | 24 | it[testName + ' from the document root'] = function(){ 25 | var tmpNode; 26 | tmpNode = context.document.createElement('div');tmpNode.setAttribute('class',className);tmpNode.setAttribute('className',className);testNode.appendChild(tmpNode); 27 | tmpNode = context.document.createElement('div');testNode.appendChild(tmpNode); 28 | tmpNode = context.document.createElement('div');testNode.appendChild(tmpNode); 29 | 30 | value_of(context.SELECT || global.context.SELECT).should_not_be_undefined(); 31 | var result = (context.SELECT || global.context.SELECT)(testNode.ownerDocument, '.' + CLASSES.join('.')); 32 | value_of( result.length ).should_be( 1 ); 33 | value_of( ('className' in result[0]) ? result[0].className : result[0].getAttribute('class') ).should_match( CLASSES.join(' ') ); 34 | }; 35 | 36 | it[testName + ' from the parent'] = function(){ 37 | var tmpNode; 38 | tmpNode = context.document.createElement('div');tmpNode.setAttribute('class',className);tmpNode.setAttribute('className',className);testNode.appendChild(tmpNode); 39 | tmpNode = context.document.createElement('div');testNode.appendChild(tmpNode); 40 | tmpNode = context.document.createElement('div');testNode.appendChild(tmpNode); 41 | 42 | value_of(context.SELECT || global.context.SELECT).should_not_be_undefined(); 43 | var result = (context.SELECT || global.context.SELECT)(testNode, '.' + CLASSES.join('.')); 44 | value_of( result.length ).should_be( 1 ); 45 | value_of( ('className' in result[0]) ? result[0].className : result[0].getAttribute('class') ).should_match( CLASSES.join(' ') ); 46 | }; 47 | 48 | it[testName + ' orphaned'] = function(){ 49 | var tmpNode; 50 | tmpNode = context.document.createElement('div');tmpNode.setAttribute('class',className);tmpNode.setAttribute('className',className);testNodeOrphaned.appendChild(tmpNode); 51 | tmpNode = context.document.createElement('div');testNodeOrphaned.appendChild(tmpNode); 52 | tmpNode = context.document.createElement('div');testNodeOrphaned.appendChild(tmpNode); 53 | 54 | value_of(context.SELECT || global.context.SELECT).should_not_be_undefined(); 55 | var result = (context.SELECT || global.context.SELECT)(testNodeOrphaned, '.' + CLASSES.join('.')); 56 | value_of( result.length ).should_be( 1 ); 57 | value_of( ('className' in result[0]) ? result[0].className : result[0].getAttribute('class') ).should_match( CLASSES.join(' ') ); 58 | }; 59 | 60 | // it should match this class as a second class 61 | if (CLASSES.length == 1) it_should_select_classes(['foo',CLASSES[0]]); 62 | }; 63 | 64 | it_should_select_classes(CLASSES); 65 | for (var i=0; i < CLASSES.length; i++) 66 | it_should_select_classes([CLASSES[i]]); 67 | 68 | }); 69 | 70 | }; 71 | -------------------------------------------------------------------------------- /speed/jslitmus/bench_match.js: -------------------------------------------------------------------------------- 1 | // -*- Mode: JavaScript; tab-width: 4; -*- 2 | var local = {}; 3 | local.collectionToArray = function(node){ 4 | return Array.prototype.slice.call(node); 5 | }; 6 | try{ 7 | local.collectionToArray(root.childNodes); 8 | } 9 | catch(e){ 10 | local.collectionToArray = function(node){ 11 | if (node instanceof Array) return node; 12 | var i = node.length, array = new Array(i); 13 | while (i--) array[i] = node[i]; 14 | return array; 15 | }; 16 | } 17 | 18 | function qsaMatch(node,selector){ 19 | var results = local.collectionToArray(node.ownerDocument.querySelectorAll(selector)); 20 | for (var i=0; i < results.length; i++) if (results[i] === node) return true; 21 | return false; 22 | } 23 | 24 | function benchmarkSelectors(specs,context){ 25 | var selectors = global.selectors; 26 | if (global.disableQSA) { 27 | try{ 28 | context.document.querySelector = null; 29 | context.Element.prototype.querySelectorAll = null; 30 | context.document.querySelector = null; 31 | context.Element.prototype.querySelector = null; 32 | }catch(e){} 33 | } 34 | 35 | global.SlickLast.debug = function(error){ 36 | throw error; 37 | }; 38 | global.SlickThis.debug = function(error){ 39 | throw error; 40 | }; 41 | 42 | if (context.document.querySelectorAll) { 43 | // it['QSA Array'] = _benchmarkSelectors(qsaMatch, context, selectors); 44 | it['Slick WIP'] = _benchmarkSelectors(function(node,selector){ return global.SlickThis.match(node,selector); }, context, selectors, function(){global.SlickThis.disableQSA = false;}); 45 | it['Slick Stable'] = _benchmarkSelectors(function(node,selector){ return global.SlickLast.match(node,selector); }, context, selectors, function(){global.SlickLast.disableQSA = false;}); 46 | } 47 | else { 48 | it['Slick WIP noQSA'] = _benchmarkSelectors(function(node,selector){ return global.SlickThis.match(node,selector); }, context, selectors, function(){global.SlickThis.disableQSA = true;}); 49 | it['Slick Stable noQSA'] = _benchmarkSelectors(function(node,selector){ return global.SlickLast.match(node,selector); }, context, selectors, function(){global.SlickLast.disableQSA = true;}); 50 | } 51 | 52 | if (global.Sizzle) { 53 | it['Sizzle'] = _benchmarkSelectors(function(node,selector){ return !!global.Sizzle.matches(selector,[node]).length; }, context, selectors); 54 | } 55 | 56 | if (global.NW) { 57 | it['NWm'] = _benchmarkSelectors(function(node,selector){ return global.NW.Dom.match(node,selector); }, context, selectors); 58 | } 59 | 60 | // if (global.yass) { 61 | // // global.yass.setCache(false); 62 | // it['YASS'] = _benchmarkSelectors(function(doc,selector){ return global.yass(selector,doc,true); }, context, selectors); 63 | // } 64 | 65 | if (global.Sly) { 66 | it['Sly'] = _benchmarkSelectors(function(doc,selector){ return global.Sly.match(selector,doc); }, context, selectors); 67 | } 68 | } 69 | 70 | function _benchmarkSelectors(MATCH,context,selectors,before,after){ 71 | function __benchmarkSelectors(count){ 72 | var document = context.document; 73 | var i, ii, node, l; 74 | var elements = document.getElementsByTagName('*'); 75 | before = before || function(){}; 76 | after = after || function(){}; 77 | before(context); 78 | var results = {}; 79 | 80 | while(count--){ 81 | for (ii=0; ii < selectors.length; ii++) if (selectors[ii]){ 82 | results[selectors[ii]] = 0; 83 | for (var Ei=0, node; node = elements[Ei++];) { 84 | try{ 85 | if (MATCH(node, selectors[ii])) results[selectors[ii]] ++; 86 | }catch(error){ 87 | results[selectors[ii]] = results[selectors[ii]] + error.message; 88 | } 89 | } 90 | results[selectors[ii]] = results[selectors[ii]]; 91 | } 92 | } 93 | after(context); 94 | return results; 95 | } 96 | return __benchmarkSelectors; 97 | }; 98 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | (Slick is an official [MooTools](http://mootools.net) project) 2 | 3 | Slick 4 | ===== 5 | A new standalone selector engine that is totally slick! 6 | ------------------------------------------------------- 7 | 8 | ### Create your own custom pseudo-classes! 9 | Ever want to make your own `:my-widget(rocks)` pseudoclass? Now you can! 10 | 11 | ### Use your own custom getAttribute code! 12 | EG: Use MooTool's Element.get method or jQuery's $.attr 13 | 14 | ### Use your own parser! 15 | Want to support XPATH selectors? JSONPath selectors? Pre-cached JS Object selctors? Just swap out the default parser and make your own. 16 | 17 | ### Use the parser by itself! 18 | Want to integrate a CSS3 Selector parser into your own app somehow? Use the slick selector CSS3 parser by itself and get a JS Object representation of your selector. 19 | 20 | --- 21 | 22 | Slick Selector Engine 23 | ===================== 24 | 25 | Usage 26 | ----- 27 | 28 | ### `search` context for selector 29 | Search this context for any nodes that match this selector. 30 | 31 | Expects: 32 | * context: document or node or array of documents or nodes 33 | * selector: String or SelectorObject 34 | * (**optional**) append: Array or Object with a push method 35 | 36 | Returns: append argument or Array of 0 or more nodes 37 | 38 | Slick.search(document, "#foo > bar.baz") → [, , ] 39 | Slick.search([
    ,
      ], "li > a") → [, , ] 40 | Slick.search(document, "#foo > bar.baz", { push:function(){} }) → { push:function(){}, 0:, 1:, 2: } 41 | 42 | 43 | ### `find` first in context with selector or null 44 | Find the first node in document that matches selector or null if none are found. 45 | 46 | Expects: 47 | * context: document or node or array of documents or nodes 48 | * selector: String or SelectorObject 49 | 50 | Returns: Element or null 51 | 52 | Slick.find(document, "#foo > bar.baz") → 53 | Slick.find(node, "#does-not-exist") → null 54 | 55 | 56 | ### node `match` selector? 57 | Does this node match this selector? 58 | 59 | Expects: 60 | * node 61 | * node, String or SelectorObject 62 | 63 | Returns: true or false 64 | 65 | Slick.match(
      , "div.rocks") → true 66 | Slick.match(
      , "div.rocks") → false 67 | Slick.match(
      ,
      ) → false 68 | 69 | 70 | ### context `contains` node? 71 | Does this context contain this node? Is the context a parent of this node? 72 | 73 | Expects: 74 | * context: document or node 75 | * node: node 76 | 77 | Returns: true or false 78 | 79 | Slick.contains(
        ,
      • ) → true 80 | Slick.contains(, ) → false 81 | 82 | 83 | --- 84 | 85 | 86 | Slick CSS Selector Parser 87 | ========================= 88 | Parse a CSS selector string into a JavaScript object 89 | ---------------------------------------------------- 90 | 91 | Usage 92 | ----- 93 | 94 | ### `parse` selector into object 95 | Parse a CSS Selector String into a Selector Object. 96 | 97 | Expects: String 98 | 99 | Returns: SelectorObject 100 | 101 | Slick.parse("#foo > bar.baz") → SelectorObject 102 | 103 | 104 | SelectorObject format 105 | --------------------- 106 | 107 | ### `#foo > bar.baz` 108 | 109 | { 110 | "raw":"#foo > bar.baz", 111 | "expressions": [[ 112 | { "combinator":" ", "tag":"*", "id":"foo" }, 113 | { "combinator":">", "tag":"bar", "classList": ["baz"], "classes": [{"value":"baz", "regexp":RegExp }]} 114 | ]] 115 | } 116 | 117 | ### `h1, h2, ul > li, .things` 118 | 119 | { 120 | "raw": "h1, h2, ul > li, .things", 121 | "expressions": [ 122 | [{ "combinator":" ", "tag": "h1" }], 123 | [{ "combinator":" ", "tag": "h2" }], 124 | [{ "combinator":" ", "tag": "ul" }, { "combinator": ">", "tag": "li" }], 125 | [{ "combinator":" ", "tag": "*", "classList": ["things"], "classes": [{"value": "things", "regexp":RegExp }] }] 126 | ] 127 | } 128 | -------------------------------------------------------------------------------- /SlickSpec/mocks/Prototype-query_test.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Prototype Unit Tests 7 | 8 | 9 | 10 | 11 | 12 | 94 | 95 | -------------------------------------------------------------------------------- /SlickSpec/mocks/template_test.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Interactive Template Tester 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 80 | 81 | 82 | 83 |
        84 | 85 | 86 |
        87 | 88 |
        89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 104 | 105 | 111 | 112 | 113 | -------------------------------------------------------------------------------- /speed/jslitmus/bench_select.js: -------------------------------------------------------------------------------- 1 | // -*- Mode: JavaScript; tab-width: 4; -*- 2 | var local = {}; 3 | local.collectionToArray = function(node){ 4 | return Array.prototype.slice.call(node); 5 | }; 6 | try{ 7 | local.collectionToArray(root.childNodes); 8 | } 9 | catch(e){ 10 | local.collectionToArray = function(node){ 11 | if (node instanceof Array) return node; 12 | var i = node.length, array = new Array(i); 13 | while (i--) array[i] = node[i]; 14 | return array; 15 | }; 16 | } 17 | 18 | 19 | function benchmarkSelectors(specs,context){ 20 | var selectors = global.selectors; 21 | if (global.disableQSA) { 22 | try{ 23 | context.document.querySelector = null; 24 | context.Element.prototype.querySelectorAll = null; 25 | context.document.querySelector = null; 26 | context.Element.prototype.querySelector = null; 27 | }catch(e){} 28 | } 29 | 30 | global.SlickLast.debug = function(error){ 31 | throw error; 32 | }; 33 | global.SlickThis.debug = function(error){ 34 | throw error; 35 | }; 36 | 37 | if (context.document.querySelectorAll) { 38 | it['QSA Array'] = _benchmarkSelectors(function(searchContext,selector){ 39 | try{ 40 | return local.collectionToArray(searchContext.querySelectorAll.call(searchContext,selector)); 41 | }catch(e){} 42 | }, context, selectors); 43 | 44 | it['Slick WIP'] = _benchmarkSelectors(function(searchContext,selector){ return global.SlickThis.search(searchContext,selector); }, context, selectors, function(){global.SlickThis.disableQSA = false;}); 45 | it['Slick Stable'] = _benchmarkSelectors(function(searchContext,selector){ return global.SlickLast.search(searchContext,selector); }, context, selectors, function(){global.SlickLast.disableQSA = false;}); 46 | } 47 | 48 | it['Slick WIP noQSA'] = _benchmarkSelectors(function(searchContext,selector){ return global.SlickThis.search(searchContext,selector); }, context, selectors, function(){global.SlickThis.disableQSA = true;}); 49 | it['Slick Stable noQSA'] = _benchmarkSelectors(function(searchContext,selector){ return global.SlickLast.search(searchContext,selector); }, context, selectors, function(){global.SlickLast.disableQSA = true;}); 50 | 51 | if (global.Sizzle) { 52 | it['Sizzle'] = _benchmarkSelectors(function(searchContext,selector){ return global.Sizzle(selector,searchContext); }, context, selectors); 53 | } 54 | 55 | if (global.NW) { 56 | // global.NW.Dom.setCache(false); 57 | it['NWm'] = _benchmarkSelectors(function(searchContext,selector){ return global.NW.Dom.select(selector,searchContext); }, context, selectors); 58 | } 59 | 60 | // if (global.yass) { 61 | // // global.yass.setCache(false); 62 | // it['YASS'] = _benchmarkSelectors(function(doc,selector){ return global.yass(selector,doc,true); }, context, selectors); 63 | // } 64 | 65 | // if (global.Sly) { 66 | // it['Sly'] = _benchmarkSelectors(function(doc,selector){ return global.Sly.search(selector,doc); }, context, selectors); 67 | // } 68 | } 69 | 70 | function _benchmarkSelectors(SELECT,context,selectors,before,after){ 71 | function __benchmarkSelectors(count){ 72 | var document = context.document; 73 | var i, ii, node, l; 74 | var elements = SELECT(document,'*'); 75 | before = before || function(){}; 76 | after = after || function(){}; 77 | before(context); 78 | var results = {}; 79 | // if (global.console && global.console.profile){ 80 | // global.console.profile(SELECT+disableQSA); 81 | // for (ii=0; ii < selectors.length; ii++) { 82 | // // for (i=0; node = elements[i++];) { node._slickUID = node._cssId = null; }; 83 | // SELECT(document, selectors[ii]); 84 | // } 85 | // global.console.profileEnd(SELECT+disableQSA); 86 | // } 87 | 88 | while(count--){ 89 | for (ii=0; ii < selectors.length; ii++) if (selectors[ii]){ 90 | 91 | // for (i=0; node = elements[i++];) { node._slickUID = node._cssId = null; }; 92 | try{ 93 | results[selectors[ii]] = SELECT(document, selectors[ii]).length; 94 | }catch(error){ 95 | results[selectors[ii]] = error; 96 | try{console.log( selectors[ii] );}catch(e){}; 97 | setTimeout(function(){throw error}, 0); 98 | } 99 | 100 | } 101 | } 102 | after(context); 103 | return results; 104 | } 105 | return __benchmarkSelectors; 106 | }; 107 | -------------------------------------------------------------------------------- /SlickSpec/assets/moobugger/debugger.css: -------------------------------------------------------------------------------- 1 | body { 2 | margin: 0; 3 | padding: 0; 4 | } 5 | 6 | #debug { 7 | display: none; 8 | font-family: arial, helvetica; 9 | width: 100%; 10 | border-top: 1px solid #B9ACAC; 11 | z-index: 9999; 12 | } 13 | 14 | #debug-header { 15 | height: 16px; 16 | border-top: 1px solid #F3F1F1; 17 | border-bottom: 1px solid #B9ACAC; 18 | background: #DBD6D6; 19 | text-align: right; 20 | padding: 3px 7px 0; 21 | font-size: 10px; 22 | color: #B9ACAC; 23 | } 24 | 25 | #debug-mootools-net:link, #debug-mootools-net:visited { 26 | display: block; 27 | float: left; 28 | width: 14px; 29 | height: 14px; 30 | margin-top: -1px; 31 | background: url(images/icon.png) no-repeat top left; 32 | } 33 | 34 | #debug-mootools-net:hover, #debug-mootools-net:active { 35 | background-position: bottom left; 36 | } 37 | 38 | #debug-header span { 39 | cursor: pointer; 40 | width: 13px; 41 | height: 13px; 42 | display: block; 43 | float: right; 44 | margin-left: 5px; 45 | } 46 | 47 | #debug-header b { 48 | display: block; 49 | clear: both; 50 | } 51 | 52 | #debug-button-close { 53 | background: url(images/close.png); 54 | } 55 | 56 | #debug-button-max { 57 | background: url(images/max.png); 58 | } 59 | 60 | #debug-button-min { 61 | background: url(images/min.png); 62 | } 63 | 64 | #debug-messages { 65 | height: 133px; 66 | border-top: 1px solid #EEE; 67 | overflow: auto; 68 | background: #FFF url(images/mootools.png) no-repeat center center; 69 | } 70 | 71 | #debug-messages pre { 72 | white-space: normal; 73 | padding: 3px 5px; 74 | margin: 0; 75 | font: 11px "Andale Mono", Monaco, "Courier New"; 76 | border-bottom: 1px solid #ccc; 77 | color: #444; 78 | background-color: #FFF; 79 | } 80 | 81 | #debug-messages pre.error { 82 | background: #F0F0F0 url(images/error.png) no-repeat 5px 50%; 83 | color: #da5d0b; 84 | padding-left: 25px; 85 | } 86 | 87 | #debug-messages pre.error span.string { 88 | color: #da5d0b; 89 | } 90 | 91 | #debug-messages pre.warning { 92 | background: #F0F0F0 url(images/warning.png) no-repeat 5px 50%; 93 | color: #ce7a2a; 94 | padding-left: 25px; 95 | } 96 | 97 | #debug-messages pre.warning span.string { 98 | color: #ce7a2a; 99 | } 100 | 101 | #debug-messages pre.info { 102 | background: #F0F0F0 url(images/info.png) no-repeat 5px 50%; 103 | color: #528CE0; 104 | padding-left: 25px; 105 | } 106 | 107 | #debug-messages pre.info span.string { 108 | color: #528CE0; 109 | } 110 | 111 | #debug-messages pre.time { 112 | background: #F0F0F0 url(images/time.png) no-repeat 5px 50%; 113 | color: #111; 114 | padding-left: 25px; 115 | } 116 | 117 | #debug-messages pre.group { 118 | background: #f9f9f9 url(images/group-close.png) no-repeat 6px 50%; 119 | color: #222; 120 | padding-left: 25px; 121 | cursor: pointer; 122 | } 123 | 124 | #debug-messages pre.group-closed { 125 | background-image: url(images/group-open.png); 126 | } 127 | 128 | #debug-messages div.group { 129 | padding: 2px 0 2px 10px; 130 | background: #ccc; 131 | } 132 | 133 | #debug-messages pre.logger { 134 | color: #4373B8; 135 | } 136 | 137 | #debug-input-area { 138 | overflow: hidden; 139 | border-top: 1px solid #B9ACAC; 140 | } 141 | 142 | #debug-input { 143 | width: 100% !important; 144 | width: 90%; 145 | color: #222; 146 | font: 12px Andale Mono, Monaco, "Courier New"; 147 | margin: 0; 148 | border: 0; 149 | padding: 4px 5px 3px 30px; 150 | background: #fff url(images/lick.png) no-repeat 7px 63%; 151 | } 152 | 153 | #debug-messages a:link, #debug-messages a:visited { 154 | color: #333; 155 | text-decoration: none; 156 | } 157 | 158 | #debug-messages a:hover, #debug-messages a:active { 159 | background-color: #757E8A; 160 | color: #fff; 161 | } 162 | 163 | #debug-messages a:hover span, #debug-messages a:active span { 164 | color: #EECFCF; 165 | } 166 | 167 | #debug-messages span.number { 168 | color: #B33F3F; 169 | } 170 | 171 | #debug-messages span.boolean { 172 | color: #A652E0; 173 | } 174 | 175 | #debug-messages span.undefined, #debug-messages span.false { 176 | color: #888; 177 | background-color: #eee; 178 | } 179 | 180 | #debug-messages span.key { 181 | color: #888; 182 | } 183 | 184 | #debug-messages span.tag { 185 | color: #528CE0; 186 | } 187 | 188 | #debug-messages span.string { 189 | color: #8B9E41; 190 | } -------------------------------------------------------------------------------- /speed/jslitmus/select_id.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | :: SlickSpec 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 123 | 124 | 125 | 126 | 127 | 128 | 129 | 132 | 133 | 134 | -------------------------------------------------------------------------------- /speed/jslitmus/bench_select2.js: -------------------------------------------------------------------------------- 1 | // -*- Mode: JavaScript; tab-width: 4; -*- 2 | var local = {}; 3 | local.collectionToArray = function(node){ 4 | return Array.prototype.slice.call(node); 5 | }; 6 | try{ 7 | local.collectionToArray(root.childNodes); 8 | } 9 | catch(e){ 10 | local.collectionToArray = function(node){ 11 | if (node instanceof Array) return node; 12 | var i = node.length, array = new Array(i); 13 | while (i--) array[i] = node[i]; 14 | return array; 15 | }; 16 | } 17 | 18 | 19 | function benchmarkSelectors(specs,context){ 20 | var selectors = global.selectors; 21 | if (global.disableQSA) { 22 | try{ 23 | context.document.querySelector = null; 24 | context.Element.prototype.querySelectorAll = null; 25 | context.document.querySelector = null; 26 | context.Element.prototype.querySelector = null; 27 | }catch(e){} 28 | } 29 | 30 | global.SlickLast.debug = function(error){ 31 | throw error; 32 | }; 33 | global.SlickThis.debug = function(error){ 34 | throw error; 35 | }; 36 | 37 | context = context.document.documentElement; 38 | for (ii=0; ii < selectors.length; ii++) if (selectors[ii]){ 39 | 40 | 41 | if (context.querySelectorAll) { 42 | // it['QSA Array '] = _benchmarkSelectors(function(searchContext,selector){ 43 | // try{ 44 | // return local.collectionToArray(searchContext.querySelectorAll.call(searchContext,selector)); 45 | // }catch(e){} 46 | // }, context, selectors); 47 | 48 | it['Slick WIP '+selectors[ii]] = _benchmarkSelectors(function(searchContext,selector){ return global.SlickThis.search(searchContext,selector); }, context, selectors[ii], function(){global.SlickThis.disableQSA = false;}); 49 | it['Slick Stable '+selectors[ii]] = _benchmarkSelectors(function(searchContext,selector){ return global.SlickLast.search(searchContext,selector); }, context, selectors[ii], function(){global.SlickLast.disableQSA = false;}); 50 | } 51 | else { 52 | it['Slick WIP '+selectors[ii]] = _benchmarkSelectors(function(searchContext,selector){ return global.SlickThis.search(searchContext,selector); }, context, selectors[ii], function(){global.SlickThis.disableQSA = true;}); 53 | it['Slick Stable '+selectors[ii]] = _benchmarkSelectors(function(searchContext,selector){ return global.SlickLast.search(searchContext,selector); }, context, selectors[ii], function(){global.SlickLast.disableQSA = true;}); 54 | } 55 | // it['Slick WIP noQSA '] = _benchmarkSelectors(function(searchContext,selector){ return global.SlickThis(searchContext,selector); }, context, selectors, function(){global.SlickThis.disableQSA = true;}); 56 | // it['Slick Stable noQSA '] = _benchmarkSelectors(function(searchContext,selector){ return global.SlickLast(searchContext,selector); }, context, selectors, function(){global.SlickLast.disableQSA = true;}); 57 | // 58 | // if (global.Sizzle) { 59 | // it['Sizzle '] = _benchmarkSelectors(function(searchContext,selector){ return global.Sizzle(selector,searchContext); }, context, selectors); 60 | // } 61 | // 62 | // if (global.NW) { 63 | // global.NW.Dom.setCache(false); 64 | // it['NWm '] = _benchmarkSelectors(function(searchContext,selector){ return global.NW.Dom.select(selector,searchContext); }, context, selectors); 65 | // } 66 | // 67 | // // if (global.yass) { 68 | // // // global.yass.setCache(false); 69 | // // it['YASS'] = _benchmarkSelectors(function(doc,selector){ return global.yass(selector,doc,true); }, context, selectors); 70 | // // } 71 | // 72 | // if (global.Sly) { 73 | // it['Sly '] = _benchmarkSelectors(function(doc,selector){ return global.Sly.search(selector,doc); }, context, selectors); 74 | // } 75 | 76 | } 77 | } 78 | 79 | function _benchmarkSelectors(SELECT,context,selector,before,after){ 80 | function __benchmarkSelectors(count){ 81 | var document = context.document; 82 | var i, ii, node, l; 83 | var elements = SELECT(document,'*'); 84 | before = before || function(){}; 85 | after = after || function(){}; 86 | before(context); 87 | var results; 88 | 89 | while(count--){ 90 | 91 | for (i=0; node = elements[i++];) { 92 | //node.uniqueNumber = 93 | node._cssId = null; 94 | }; 95 | try{ 96 | results = SELECT(document, selector).length; 97 | }catch(error){ 98 | results = error; 99 | } 100 | 101 | } 102 | after(context); 103 | return results; 104 | } 105 | return __benchmarkSelectors; 106 | }; 107 | -------------------------------------------------------------------------------- /SlickSpec/SlickSpec_ownSpecs.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 113 | SlickSpec Own Specs 114 |

        SlickSpec

        115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 128 | 131 | 132 | 138 | 139 | 140 | 141 | 142 | -------------------------------------------------------------------------------- /speed/slickspeed/system/index.php: -------------------------------------------------------------------------------- 1 | 'Default', 'loose' => 'Loose DOM Fragment', 'xml' => 'XML Document'); 7 | 8 | $special = ''; 9 | if (isset($_REQUEST['special'])) { 10 | if (array_key_exists($_REQUEST['special'], $special_list)) { 11 | $special = $_REQUEST['special']; 12 | } else { 13 | $valid = false; 14 | } 15 | } 16 | 17 | $css_list = array('' => 'Default', 'simple' => 'Simple', 'extended' => 'Extended', 'yahoo' => 'Yahoo (via ejohn)', 'crazy' => 'Just crazy'); 18 | 19 | $css = ''; 20 | if (isset($_REQUEST['css'])) { 21 | if (array_key_exists($_REQUEST['css'], $css_list)) { 22 | $css = $_REQUEST['css']; 23 | } else { 24 | $valid = false; 25 | } 26 | } 27 | 28 | if (!$valid) { 29 | header('Location: ' . $_SERVER['SCRIPT_NAME']); 30 | exit; 31 | } 32 | 33 | $link = $_SERVER['SCRIPT_NAME']; 34 | 35 | if (!$valid) { 36 | header('Location: ' . $link); 37 | exit; 38 | } 39 | 40 | if ($css || $special) { 41 | $build = array(); 42 | if ($css) $build['css'] = $css; 43 | if ($special) $build['special'] = $special; 44 | $link = $link . '?' . http_build_query($build, '', '&'); 45 | } 46 | 47 | if (count($_POST)) { 48 | header('Location: ' . $link); 49 | exit; 50 | } 51 | 52 | $file = 'selectors.list.css'; 53 | if ($css) $file = 'selectors.list.' . $css . '.css'; 54 | 55 | $selectors = file_get_contents($file); 56 | 57 | ?> 58 | 60 | 61 | 62 | 63 | 64 | SlickSpeed Selectors Test 65 | 66 | 67 | 75 | 76 | 77 | 78 | 79 | 80 | 81 |
        82 | 83 |
        84 | stop tests 85 | start tests 86 |
        87 | 88 | 89 | 90 | $properties){ 93 | $time = time(); 94 | 95 | $query = http_build_query(array( 96 | 'include' => $properties['file'] . '?' . $time, 97 | 'function' => $properties['function'], 98 | 'initialize' => isset($properties['initialize']) ? $properties['initialize'] : '', 99 | 'special' => $special, 100 | 'css' => $css, 101 | 'nocache' => $time 102 | ), '', '&'); 103 | 104 | echo ''; 105 | } 106 | ?> 107 | 108 | 109 | 110 | 111 | 112 | 113 | $properties){ 115 | echo ""; 116 | } 117 | ?> 118 | 119 | 120 | 121 | 122 | "; 125 | $selector = str_replace('%', '', $selector); 126 | echo ""; 127 | foreach ($frameworks as $framework){ 128 | echo ""; 129 | } 130 | echo ""; 131 | } 132 | ?> 133 | 134 | 135 | 136 | 137 | 138 | 0"; 141 | } 142 | ?> 143 | 144 | 145 | 146 |
        selectors$framework
        $selector
        final ops/ms (more is better)
        147 | 148 |

        Legend

        149 | 150 | 151 | 152 | 153 | 154 | 155 | 156 | 157 | 158 | 159 | 160 | 161 | 162 | 163 | 164 | 165 | 166 |
        the fasterthe slowerexception thrown or zero elements founddifferent returned elements
        167 | 168 | 169 |
        170 | 171 | 172 | -------------------------------------------------------------------------------- /speed/slickspeed/system/slickspeed.js: -------------------------------------------------------------------------------- 1 | //base test functions 2 | 3 | function forEach(iterable, fn, bind){ 4 | for (var i = 0, j = iterable.length; i < j; i++) fn.call(bind, iterable[i], i, iterable); 5 | }; 6 | 7 | //test start 8 | 9 | window.onload = function load(){ 10 | 11 | var frameworks = {}; 12 | 13 | forEach(document.getElementsByTagName('iframe'), function(iframe){ 14 | frameworks[iframe.name] = { 15 | 'test': window.frames[iframe.name].test, 16 | 'selectors': [] 17 | }; 18 | }); 19 | 20 | var tbody = document.getElementById('tbody'); 21 | var tfoot = document.getElementById('tfoot'); 22 | var lastrow = tfoot.getElementsByTagName('tr')[0]; 23 | 24 | var controls = document.getElementById('controls'); 25 | 26 | var links = controls.getElementsByTagName('a'); 27 | 28 | var start = links[1]; 29 | var stop = links[0]; 30 | 31 | start.onclick = function(){ 32 | testRunner(); 33 | return false; 34 | }; 35 | 36 | stop.onclick = function(){ 37 | clearTimeout(timer); 38 | timer = null; 39 | return false; 40 | }; 41 | 42 | var score = []; 43 | var scores = {}; 44 | 45 | var frxi = 0; 46 | for (var name in frameworks){ 47 | var framework = frameworks[name]; 48 | forEach(window.selectors, function(selector){ 49 | framework.selectors.push(selector); 50 | }); 51 | scores[name] = lastrow.getElementsByTagName('td')[frxi]; 52 | score[name] = 0; 53 | frxi++; 54 | } 55 | 56 | var tests = []; 57 | 58 | forEach(window.selectors, function(selector, i){ 59 | var frxi = 0; 60 | var row = tbody.getElementsByTagName('tr')[i]; 61 | for (var name in frameworks){ 62 | var framework = frameworks[name]; 63 | var cell = row.getElementsByTagName('td')[frxi]; 64 | tests.push({ 65 | 'execute': framework.test, 66 | 'selector': framework.selectors[i], 67 | 'name': name, 68 | 'row': row, 69 | 'cell' : cell 70 | }); 71 | frxi++; 72 | } 73 | }); 74 | 75 | var timer = null; 76 | 77 | var testRunner = function(){ 78 | var test = tests.shift(); 79 | if (!test) return; 80 | var results = test.execute(test.selector); 81 | function handleResults(){ 82 | var ops = results && results.ops || 0; 83 | test.cell.className = 'test'; 84 | test.cell.innerHTML = ''+Math.round(ops * 10)/10 + ' ops/ms' + results.found + ' found'; 85 | test.cell.speed = results.ops || 0; 86 | if (results.error){ 87 | test.cell.innerHTML = ops + ' ops/s | error returned'; 88 | test.cell.className += ' exception'; 89 | test.cell.found = 0; 90 | test.cell.error = true; 91 | } else { 92 | test.cell.found = results.found; 93 | test.cell.error = false; 94 | } 95 | 96 | score[test.name] += test.cell.speed; 97 | scores[test.name].innerHTML = ' ' + Math.round(score[test.name]) + ' '; 98 | 99 | if (test.cell == test.row.lastChild) colourRow(test.row); 100 | }; 101 | // setTimeout(handleResults,100); 102 | handleResults(); 103 | timer = setTimeout(testRunner,0); 104 | }; 105 | 106 | var colourRow = function(row){ 107 | 108 | var cells = []; 109 | 110 | var tds = row.getElementsByTagName('td'); 111 | forEach(tds, function(td){ 112 | cells.push(td); 113 | }); 114 | 115 | var speeds = [], sum = 0, length = 0; 116 | 117 | forEach(cells, function(cell, i){ 118 | if (!cell.error) { 119 | sum += cell.speed; 120 | length++; 121 | speeds[i] = cell.speed; 122 | } 123 | //error, so we exclude it from colouring 124 | else speeds[i] = 99999999999999999999999; 125 | 126 | }); 127 | 128 | var avg = sum / length; 129 | 130 | var min = Math.min.apply(this, speeds); 131 | var max = Math.max.apply(this, speeds); 132 | 133 | var found = []; 134 | var mismatch = false; 135 | forEach(cells, function(cell, i){ 136 | found.push(cell.found); 137 | if (!mismatch){ 138 | forEach(found, function(n){ 139 | if (cell.found && n && cell.found != n){ 140 | mismatch = true; 141 | return; 142 | } 143 | }); 144 | } 145 | cell.title = cell.firstChild.innerHTML; 146 | cell.firstChild.innerHTML += " " + (Math.round(cell.speed / avg * 10) / 10) + 'x' + ""; 147 | if (cell.found && cell.speed == max) cell.className += ' good'; 148 | else if (!cell.found) cell.className += ' zero'; 149 | else if (cell.speed == min) cell.className += ' bad'; 150 | else cell.className += ' normal'; 151 | }); 152 | 153 | if (mismatch){ 154 | forEach(cells, function(cell, i){ 155 | if (cell.found) cell.className += ' mismatch'; 156 | }); 157 | } 158 | 159 | }; 160 | 161 | 162 | }; 163 | -------------------------------------------------------------------------------- /speed/slickspeed/system/template.php: -------------------------------------------------------------------------------- 1 | 4 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 139 | 140 | 141 | 142 | 143 | 144 | 145 | 146 | 147 | 148 | -------------------------------------------------------------------------------- /SlickSpec/assets/JSSpec.css: -------------------------------------------------------------------------------- 1 | @CHARSET "UTF-8"; 2 | 3 | /* -------------------- 4 | * @Layout 5 | */ 6 | 7 | html { 8 | overflow: hidden; 9 | } 10 | 11 | body, #jsspec_container { 12 | overflow: hidden; 13 | padding: 0; 14 | margin: 0; 15 | width: 100%; 16 | height: 100%; 17 | background-color: white; 18 | } 19 | 20 | #title { 21 | padding: 0; 22 | margin: 0; 23 | position: absolute; 24 | top: 0px; 25 | left: 0px; 26 | width: 100%; 27 | height: 40px; 28 | overflow: hidden; 29 | } 30 | 31 | #list { 32 | padding: 0; 33 | margin: 0; 34 | position: absolute; 35 | top: 40px; 36 | left: 0px; 37 | bottom: 0px; 38 | overflow: auto; 39 | width: 250px; 40 | _height:expression(document.body.clientHeight-40); 41 | } 42 | 43 | #log { 44 | padding: 0; 45 | margin: 0; 46 | position: absolute; 47 | top: 40px; 48 | left: 250px; 49 | right: 0px; 50 | bottom: 0px; 51 | overflow: auto; 52 | _height:expression(document.body.clientHeight-40); 53 | _width:expression(document.body.clientWidth-250); 54 | } 55 | 56 | /*iPhone*/ 57 | @media only screen and (max-device-width: 480px) { 58 | #list { 59 | overflow: visible; 60 | } 61 | 62 | #log { 63 | overflow: visible; 64 | } 65 | } 66 | 67 | 68 | /* -------------------- 69 | * @Decorations and colors 70 | */ 71 | * { 72 | padding: 0; 73 | margin: 0; 74 | font-family: "Lucida Grande", Helvetica, sans-serif; 75 | } 76 | 77 | li { 78 | list-style: none; 79 | } 80 | 81 | /* hiding subtitles */ 82 | h2 { 83 | display: none; 84 | } 85 | 86 | /* title section */ 87 | div#title { 88 | padding: 0em 0.5em; 89 | } 90 | 91 | div#title h1 { 92 | font-size: 1.5em; 93 | float: left; 94 | } 95 | 96 | div#title ul li { 97 | float: left; 98 | padding: 0.5em 0em 0.5em 0.75em; 99 | } 100 | 101 | div#title p { 102 | float:right; 103 | margin-right:1em; 104 | font-size: 0.75em; 105 | } 106 | 107 | /* spec container */ 108 | ul.specs { 109 | margin: 0.5em; 110 | } 111 | ul.specs li { 112 | margin-bottom: 0.1em; 113 | } 114 | 115 | /* spec title */ 116 | ul.specs li h3 { 117 | font-weight: bold; 118 | font-size: 0.75em; 119 | padding: 0.2em 1em; 120 | cursor: pointer; 121 | _cursor: hand; 122 | } 123 | 124 | /* example container */ 125 | ul.examples li { 126 | border-style: solid; 127 | border-width: 0px 0px 1px 5px; 128 | margin: 0.2em 0em 0.2em 1em; 129 | } 130 | 131 | /* example title */ 132 | ul.examples li h4 { 133 | font-weight: normal; 134 | font-size: 0.75em; 135 | margin-left: 1em; 136 | } 137 | 138 | pre.examples-code { 139 | margin: 0.5em 2em; 140 | padding: 0.5em; 141 | background: white; 142 | border: solid 1px #CCC; 143 | font-size: 10px; 144 | font-family: "Panic Sans", "Monaco", monospace !important; 145 | } 146 | 147 | /* example explaination */ 148 | ul.examples li div { 149 | padding: 1em 2em; 150 | font-size: 0.75em; 151 | } 152 | 153 | /* styles for ongoing, success, failure, error */ 154 | div.success, div.success a { 155 | color: #FFFFFF; 156 | background-color: #65C400; 157 | } 158 | 159 | li.ongoing li.success pre.examples-code, 160 | li pre.examples-code { 161 | display:none !important; 162 | } 163 | li.exception pre.examples-code, 164 | li.ongoing pre.examples-code { 165 | display:block !important; 166 | } 167 | 168 | ul.specs li.success h3, ul.specs li.success h3 a { 169 | color: #FFFFFF; 170 | background-color: #65C400; 171 | } 172 | 173 | ul.examples li.success, ul.examples li.success a { 174 | color: #3D7700; 175 | background-color: #DBFFB4; 176 | border-color: #65C400; 177 | } 178 | 179 | div.exception, div.exception a { 180 | color: #FFFFFF; 181 | background-color: #C20000; 182 | } 183 | 184 | ul.specs li.exception h3, ul.specs li.exception h3 a { 185 | color: #FFFFFF; 186 | background-color: #C20000; 187 | } 188 | 189 | ul.examples li.exception, ul.examples li.exception a { 190 | color: #C20000; 191 | background-color: #FFFBD3; 192 | border-color: #C20000; 193 | } 194 | 195 | div.ongoing, div.ongoing a { 196 | color: #000000; 197 | background-color: #FFFF80; 198 | } 199 | 200 | ul.specs li.ongoing h3, ul.specs li.ongoing h3 a { 201 | color: #000000; 202 | background-color: #FFFF80; 203 | } 204 | 205 | ul.examples li.ongoing, ul.examples li.ongoing a { 206 | color: #000000; 207 | background-color: #FFFF80; 208 | border-color: #DDDD00; 209 | } 210 | 211 | 212 | 213 | /* -------------------- 214 | * values 215 | */ 216 | .number_value, .string_value, .regexp_value, .boolean_value, .dom_value { 217 | font-family: monospace; 218 | color: blue; 219 | } 220 | .object_value, .array_value { 221 | line-height: 2em; 222 | padding: 0.1em 0.2em; 223 | margin: 0.1em 0; 224 | } 225 | .date_value { 226 | font-family: monospace; 227 | color: olive; 228 | } 229 | .undefined_value, .null_value { 230 | font-style: italic; 231 | color: blue; 232 | } 233 | .dom_attr_name { 234 | } 235 | .dom_attr_value { 236 | color: red; 237 | } 238 | .dom_path { 239 | font-size: 0.75em; 240 | color: gray; 241 | } 242 | strong { 243 | font-weight: normal; 244 | background-color: #FFC6C6; 245 | } 246 | -------------------------------------------------------------------------------- /SlickSpec/select.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 74 | SlickSpec Select 75 |

        SlickSpec

        76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 92 | 93 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | 110 | -------------------------------------------------------------------------------- /SlickSpec/assets/moobugger/test.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | 7 | 8 | the moobugger 9 | 10 | 11 | 12 | 35 | 36 | 37 | 38 | 39 | 40 | 41 |
        42 |

        The MooBugger.

        43 | 44 |

        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

        45 | 46 |

        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

        47 | 48 |

        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

        49 | 50 |

        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

        51 | 52 |

        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

        53 | 54 |

        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

        55 | 56 |

        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

        57 | 58 |

        Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

        59 |
        60 | 61 | 85 | 86 | 87 | 88 | -------------------------------------------------------------------------------- /speed/jslitmus/selectXML.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | :: SlickSpec 6 | 7 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 22 | 23 | 24 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 130 | 131 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /SlickSpec/specs/slick_match_specs.js: -------------------------------------------------------------------------------- 1 | function specsMatch(){ 2 | 3 | var nodes = {}; 4 | 5 | Describe('Slick Match',function(specs, context){ 6 | 7 | specs.before_each = function() { 8 | nodeWithoutParent = document.createElement('div'); 9 | testNode = nodeWithoutParent; 10 | }; 11 | specs.after_each = function() { 12 | for (var name in nodes) { 13 | delete nodes[name]; 14 | } 15 | }; 16 | 17 | its['node should match another node'] = function(){ 18 | 19 | value_of( context.MATCH(testNode, testNode) ).should_be_true(); 20 | value_of( context.MATCH(testNode, document.createElement('div')) ).should_be_false(); 21 | 22 | }; 23 | 24 | its['node should NOT match nothing'] = function(){ 25 | 26 | value_of( context.MATCH(testNode) ).should_be_false(); 27 | value_of( context.MATCH(testNode, null) ).should_be_false(); 28 | value_of( context.MATCH(testNode, undefined) ).should_be_false(); 29 | value_of( context.MATCH(testNode, '') ).should_be_false(); 30 | 31 | }; 32 | 33 | 34 | 35 | Describe('attributes',function(){ 36 | 37 | var nodes; 38 | 39 | var AttributeTests = [ 40 | { operator:'=', value:'test you!', matchAgainst:'test you!', shouldBeTrue:true }, 41 | { operator:'=', value:'test you!', matchAgainst:'test me!', shouldBeTrue:false }, 42 | 43 | { operator:'^=', value:'test', matchAgainst:'test you!', shouldBeTrue:true }, 44 | { operator:'^=', value:'test', matchAgainst:' test you!', shouldBeTrue:false }, 45 | 46 | { operator:'$=', value:'you!', matchAgainst:'test you!', shouldBeTrue:true }, 47 | { operator:'$=', value:'you!', matchAgainst:'test you! ', shouldBeTrue:false }, 48 | 49 | { operator:'!=', value:'test you!', matchAgainst:'test you?', shouldBeTrue:true }, 50 | { operator:'!=', value:'test you!', matchAgainst:'test you!', shouldBeTrue:false } 51 | ]; 52 | function makeAttributeTest(operator, value, matchAgainst, shouldBeTrue) { 53 | return function(){ 54 | testNode.setAttribute('attr', matchAgainst); 55 | value_of( context.MATCH(testNode, "[attr"+ operator +"'"+ value +"']") )[shouldBeTrue ? 'should_be_true' : 'should_be_false'](); 56 | testNode.removeAttribute('attr'); 57 | }; 58 | } 59 | for (var t=0,J; J=AttributeTests[t]; t++) 60 | its['"'+J.matchAgainst+'" should '+ (J.shouldBeTrue?'':'NOT') +" match \"[attr"+ J.operator +"'"+ String.escapeSingle(J.matchAgainst) +"']\""] = 61 | makeAttributeTest(J.operator, J.value, J.matchAgainst, J.shouldBeTrue); 62 | }); 63 | 64 | Describe('classes',function(){ 65 | 66 | // it['should match all possible classes'] = TODO; 67 | 68 | }); 69 | 70 | Describe('pseudos',function(){ 71 | 72 | // it['should match all standard pseudos'] = TODO; 73 | 74 | }); 75 | 76 | 77 | }); 78 | 79 | Describe('Slick Deep Match',function(specs, context){ 80 | 81 | specs.before_each = function() { 82 | 83 | testNode = context.document.createElement('div'); 84 | testNode.innerHTML = '\ 85 | \ 86 | lorem \ 87 | \ 88 | \ 89 | \ 90 | lorem\ 91 | \ 92 | \ 93 | '; 94 | context.document.body.appendChild(testNode); 95 | 96 | nested_a = context.document.getElementById('a_tag1'); 97 | }; 98 | specs.after_each = function() { 99 | for (var name in nodes) { 100 | if (nodes[name] && nodes[name].parentNode) { 101 | nodes[name].parentNode.removeChild(nodes[name]); 102 | } 103 | delete nodes[name]; 104 | } 105 | }; 106 | 107 | 108 | function it_should_match_selector(node, selector, should_be){ 109 | it['should match selector "' + selector + '"'] = function(){ 110 | 111 | value_of( context.MATCH(global[node], selector) ).should_be(should_be); 112 | 113 | }; 114 | }; 115 | 116 | it_should_match_selector('nested_a', '*' ,true ); 117 | it_should_match_selector('nested_a', 'a' ,true ); 118 | it_should_match_selector('nested_a', ':not(a)' ,false ); 119 | it_should_match_selector('nested_a', 'del' ,false ); 120 | it_should_match_selector('nested_a', ':not(del)' ,true ); 121 | it_should_match_selector('nested_a', '[id]' ,true ); 122 | it_should_match_selector('nested_a', ':not([id])' ,false ); 123 | it_should_match_selector('nested_a', '[class]' ,true ); 124 | it_should_match_selector('nested_a', ':not([class])' ,false ); 125 | it_should_match_selector('nested_a', '.a' ,true ); 126 | it_should_match_selector('nested_a', ':not(.a)' ,false ); 127 | 128 | it_should_match_selector('nested_a', '* *' ,true ); 129 | it_should_match_selector('nested_a', '* > *' ,true ); 130 | it_should_match_selector('nested_a', '* ~ *' ,false ); 131 | it_should_match_selector('nested_a', '* + *' ,false ); 132 | it_should_match_selector('nested_a', 'b a' ,true ); 133 | it_should_match_selector('nested_a', 'b > a' ,true ); 134 | it_should_match_selector('nested_a', 'div > b > a' ,true ); 135 | it_should_match_selector('nested_a', 'div > b + b > a' ,true ); 136 | it_should_match_selector('nested_a', 'div > b ~ b > a' ,true ); 137 | it_should_match_selector('nested_a', 'div a' ,true ); 138 | 139 | // it['should match a node outside the DOM'] = TODO; 140 | 141 | // it['should match a node on a different window/iframe'] = TODO; 142 | 143 | }); 144 | 145 | }; 146 | -------------------------------------------------------------------------------- /speed/subtleslickspeed/lib/table_report.css: -------------------------------------------------------------------------------- 1 | 2 | #report table{ 3 | table-layout:fixed; 4 | } 5 | #report table td{ 6 | margin:0;padding:0; 7 | vertical-align: top; 8 | } 9 | 10 | #report td div.bgw{ 11 | background: #E4EBF9; 12 | background: #0072AB; 13 | /* color: #68B3D8;*/ 14 | 15 | /* -moz-border-radius: 6px;*/ 16 | -webkit-border-radius: 6px; 17 | overflow:hidden; 18 | padding:1px 2px; 19 | line-height: 16px; 20 | 21 | margin: 0 3px; 22 | } 23 | #report td div.bgw div{ 24 | white-space: nowrap; 25 | background: #333; 26 | color:#fff; 27 | 28 | background: #0072AB !important; 29 | background: #fff !important; 30 | color:#0072AB; 31 | 32 | font-size: 10px; 33 | /* text-indent:0.5em;*/ 34 | 35 | /* -moz-border-radius: 6px;*/ 36 | -webkit-border-radius: 6px; 37 | overflow:visible; 38 | 39 | margin:0 auto; 40 | text-align: center; 41 | } 42 | 43 | #report td strong{ 44 | padding: 0.25em; 45 | white-space:nowrap; 46 | } 47 | #report td strong em{ 48 | font-weight:normal; 49 | } 50 | #report td .wrap{ 51 | position:relative; 52 | } 53 | #report td a.rerun{ 54 | float:right; 55 | visibility:hidden; 56 | _visibility:visible; 57 | 58 | color: #FB1A75; 59 | -webkit-box-shadow: 0px 1px 5px #000; 60 | 61 | /* background:#E4EBF9;*/ 62 | margin:0;padding:0; 63 | 64 | position: absolute; 65 | top: 0px; 66 | left: 0px; 67 | width:100%; 68 | height:100%; 69 | z-index: 100; 70 | 71 | text-align:center; 72 | font-size:2em; 73 | font-family: Garamond, serif; 74 | text-decoration: none; 75 | 76 | -ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)"; 77 | filter:alpha(opacity=80); 78 | -moz-opacity: 0.8; 79 | opacity: 0.8; 80 | 81 | -moz-border-radius: 9px; 82 | -webkit-border-radius: 9px; 83 | border:5px solid; 84 | margin:-5px; 85 | } 86 | #report td:hover a.rerun{ 87 | visibility:visible; 88 | } 89 | 90 | td div.bgw div{ 91 | display:none; 92 | } 93 | #report-wrap.selector td div.bgw div.selector, 94 | #report-wrap.framework td div.bgw div.framework, 95 | #report-wrap.All td div.bgw div.All, 96 | #report-wrap.show_all td div.bgw div{ 97 | display:block !important; 98 | } 99 | 100 | 101 | .toolbar{ 102 | background:#eee; 103 | padding: 1em 1.5em; 104 | } 105 | 106 | .toolbar label{ 107 | padding-left:0.5em; 108 | } 109 | 110 | .toolbar input.number{ 111 | text-align:right; 112 | } 113 | 114 | #report.hide_info td strong{ 115 | display:none; 116 | } 117 | 118 | /* @group Selector */ 119 | #report-wrap.selector #report.hide_info tr:hover td strong{ 120 | display:inline; 121 | } 122 | 123 | #report-wrap.selector #report.hide_info tr td strong{ 124 | /* display:block;*/ 125 | font-size: 12px; 126 | line-height: 18px; 127 | margin:0;padding:0; 128 | 129 | position: absolute; 130 | top: 0px; 131 | left: 0px; 132 | width:100%; 133 | 134 | color:#fff; 135 | text-shadow: 0px 1px 1px #0072AB; 136 | } 137 | #report-wrap.selector #report.hide_info tr td strong.sec{ 138 | top:17px !important; 139 | } 140 | #report-wrap.selector #report.hide_info tr td strong.result{ 141 | top:34px !important; 142 | } 143 | #report-wrap.selector #report.hide_info tr:hover td div.bgw div{ 144 | background:#3A9CCC !important; 145 | color:#3A9CCC; 146 | } 147 | 148 | #report-wrap.selector tr td{ 149 | text-align:center; 150 | } 151 | #report-wrap.selector tr td div.bgw{ 152 | margin:1px 0; 153 | padding:0; 154 | -moz-border-radius: 0px; 155 | -webkit-border-radius: 0px; 156 | } 157 | #report-wrap.selector tr td div.bgw{ 158 | background: #E4EBF9; 159 | } 160 | /*#report-wrap.selector tr:first-child td,*/ 161 | #report-wrap.selector tr td:first-child{ 162 | background:none; 163 | color: #000; 164 | padding-right:1em; 165 | vertical-align: middle; 166 | } 167 | 168 | #report-wrap.selector tr td div.bgw{ 169 | background: #0072AB; 170 | margin:6px 0; 171 | padding: 0 1px; 172 | height:2em; 173 | font-size:2em; 174 | position:relative; 175 | border-top: 2px solid #0072AB !important; 176 | border-bottom: 2px solid #0072AB !important; 177 | } 178 | #report-wrap.selector tr td div.bgw div{ 179 | /* opacity:1 !important;*/ 180 | width:99% !important; 181 | /* height:3em !important;*/ 182 | line-height:2em; 183 | /* overflow:hidden;*/ 184 | background: #fff !important; 185 | color:#0072AB; 186 | position: absolute; 187 | bottom: 0px; 188 | left: 1%; 189 | -webkit-border-bottom-left-radius:0 !important; 190 | -webkit-border-bottom-right-radius:0 !important; 191 | } 192 | #report-wrap tr:hover td div.bgw div{ 193 | opacity:1 !important; 194 | } 195 | 196 | /* @end Selector */ 197 | 198 | /* @group framework */ 199 | 200 | #report-wrap.framework tr td:nth-child(odd) div.bgw{ 201 | background: #3A9CCC; 202 | } 203 | #report-wrap.framework tr td div.bgw{ 204 | font-size:1em !important; 205 | } 206 | #report-wrap.framework tr td div.bgw div{ 207 | font-size:1em !important; 208 | } 209 | 210 | /* @end framework */ 211 | 212 | /* @group All */ 213 | 214 | #report-wrap.All tr td div.bgw{ 215 | background: #E4EBF9; 216 | margin:2px; 217 | font-size:1em !important; 218 | } 219 | #report-wrap.All tr td div.bgw div{ 220 | background: #67B0D3 !important; 221 | margin:0; 222 | color:#000; 223 | font-size:1em !important; 224 | text-align:left; 225 | text-indent:0.25em; 226 | opacity:1 !important; 227 | } 228 | 229 | /* @end All */ 230 | 231 | 232 | #report{ 233 | margin:2em 0; 234 | } 235 | #report td h3{ 236 | padding: 0 1em; 237 | height: 2em; 238 | line-height:1em; 239 | } 240 | 241 | 242 | -------------------------------------------------------------------------------- /speed/subtleslickspeed/tests/selectors/tests.js: -------------------------------------------------------------------------------- 1 | if (!window.didThisAlready) { 2 | 3 | var SELECTORS = SELECTORS || '\ 4 | body\n\ 5 | div\n\ 6 | span\n\ 7 | a\n\ 8 | a.fn\n\ 9 | a.url\n\ 10 | a.fn.url\n\ 11 | body\n\ 12 | div\n\ 13 | body div\n\ 14 | div p\n\ 15 | div > p\n\ 16 | div + p\n\ 17 | div ~ p\n\ 18 | div[class^=exa][class$=mple]\n\ 19 | div p a\n\ 20 | div, p, a\n\ 21 | .note\n\ 22 | div.example\n\ 23 | ul .tocline2\n\ 24 | div.example, div.note\n\ 25 | #title\n\ 26 | h1#title\n\ 27 | div #title\n\ 28 | ul.toc li.tocline2\n\ 29 | ul.toc > li.tocline2\n\ 30 | h1#title + div > p\n\ 31 | h1[id]:contains(Selectors)\n\ 32 | a[href][lang][class]\n\ 33 | div[class]\n\ 34 | div[class=example]\n\ 35 | div[class^=exa]\n\ 36 | div[class$=mple]\n\ 37 | div[class*=e]\n\ 38 | div[class|=dialog]\n\ 39 | div[class!=made_up]\n\ 40 | div[class~=example]\n\ 41 | div:not(.example)\n\ 42 | p:contains(selectors)\n\ 43 | p:nth-child(even)\n\ 44 | p:nth-child(2n)\n\ 45 | p:nth-child(odd)\n\ 46 | p:nth-child(2n+1)\n\ 47 | p:nth-child(n)\n\ 48 | p:only-child\n\ 49 | p:last-child\n\ 50 | p:first-child\n\ 51 | '; 52 | 53 | document.getElementById('SELECTORS').innerHTML = SELECTORS; 54 | SELECTORS = SELECTORS.split(/\r?\n/); 55 | var q = Object.fromQueryString(document.location.search); 56 | 57 | function loadFrameworkTests(framework){ 58 | var url = 'lib/frameworks/'+framework.js+'.js'; 59 | var sandbox = new SubtleSlickSpeed.Test.Sandboxed(framework.name, ["tests/selectors/template.js", url]); 60 | 61 | if (disableQSA) sandbox.eval('document.querySelectorAll = undefined;Element.prototype.querySelectorAll = undefined;'); 62 | if (disableGBC) sandbox.eval('document.getElementsByClassName = undefined;Element.prototype.getElementsByClassName = undefined;'); 63 | sandbox.addEvent('load:'+url, function(){ 64 | 65 | // framework.queryFn = sandbox.eval(framework.queryFn); 66 | 67 | Array.each(SELECTORS, function(selector){ 68 | if (!selector) return; 69 | // console.log(selector); 70 | // sandbox.eval("document.querySelectorAll = undefined; Element.prototype.querySelectorAll = undefined;"); 71 | framework.runBefore && sandbox.eval(framework.runBefore); 72 | sandbox.eval("new SubtleSlickSpeed.Test('"+selector+";;;"+String.escapeSingle(framework.name)+"', function(){ return "+framework.queryFn+"('"+String.escapeSingle(selector)+"').length; })"); 73 | // with (sandbox.window) 74 | // new SubtleSlickSpeed.Test(selector+";;;"+framework.name, function(){ 75 | // return framework.queryFn(selector); 76 | // }); 77 | }); 78 | }); 79 | } 80 | 81 | var Frameworks = { 82 | // 'jQuery 1.2.6':{ 83 | // js:'jq-126', 84 | // queryFn:'$' 85 | // }, 86 | // 'jQuery 1.3.2':{ 87 | // js:'jq-132', 88 | // queryFn:'$' 89 | // }, 90 | // 'Dojo 1.3':{ 91 | // js:'dojo', 92 | // queryFn:'dojo.query' 93 | // }, 94 | // 'Prototype 1.6.0.3':{ 95 | // js:'proto-1603', 96 | // queryFn:'$$' 97 | // }, 98 | 'MooTools 1.2.4':{ 99 | js:'../../../frameworks/mootools', 100 | queryFn:'$$' 101 | }, 102 | // 'Slick (parse only)':{ 103 | // js:'slick', 104 | // queryFn:'SubtleSlickParse' 105 | // }, 106 | // 'Slick (parse only) nocache':{ 107 | // js:'slick', 108 | // queryFn:'SubtleSlickParse.nocache=true; SubtleSlickParse' 109 | // }, 110 | // 'NW Matcher 1.1.1':{ 111 | // js:'nwmatcher', 112 | // runBefore:'NW.Dom.setCache(false);', 113 | // queryFn:'NW.Dom.select' 114 | // }, 115 | // 'Sly v1.0rc2':{ 116 | // js:'sly', 117 | // queryFn:'Sly.search' 118 | // }, 119 | 'Slick Stable':{ 120 | js:'../../../frameworks/slick', 121 | runBefore:'document.search = function(selector){return Slick(document,selector)};', 122 | queryFn:'document.search' 123 | }, 124 | 'Slick WIP':{ 125 | js:'../../../../slick', 126 | runBefore:'document.search = function(selector){return Slick(document,selector)};', 127 | queryFn:'document.search' 128 | // }, 129 | // 'Evil Slick':{ 130 | // js:'slick_dsl', 131 | // runBefore:'Matcher.nocache=false;SubtleSlickParse.nocache=true;', 132 | // queryFn:'document.search' 133 | // }, 134 | // 'Evil Slick (no-cache)':{ 135 | // js:'slick_dsl', 136 | // runBefore:'Matcher.nocache=true;SubtleSlickParse.nocache=true;', 137 | // queryFn:'document.search' 138 | } 139 | }; 140 | 141 | function shouldExclude(str){ 142 | if (!q.exclude) return false; 143 | 144 | q.exclude = $splat(q.exclude); 145 | 146 | for (var i = q.exclude.length - 1; i >= 0; i--){ 147 | if (q.exclude[i] == str) return true; 148 | } 149 | return false; 150 | }; 151 | 152 | Array.each(SELECTORS, UID.uidOf); 153 | Object.each(Frameworks, function(framework, frameworkName){ 154 | 155 | UID.uidOf(frameworkName); 156 | Array.each(SELECTORS, function(selector){ 157 | UID.uidOf(selector + frameworkName); 158 | }); 159 | 160 | framework.name = frameworkName; 161 | // console.log(q.exclude.indexOf(frameworkName)) 162 | if (!shouldExclude(Frameworks[frameworkName].js)) 163 | loadFrameworkTests(framework); 164 | else 165 | Frameworks[frameworkName].stop = true; 166 | }); 167 | 168 | var html = [], ex = document.getElementById('exclude'); 169 | html.push('Exclude: '); 170 | for (var frameworkName in Frameworks) { 171 | html.push(''); 172 | } 173 | // html.push('') 174 | ex.innerHTML = html.join(''); 175 | 176 | 177 | window.didThisAlready = true;} 178 | -------------------------------------------------------------------------------- /speed/jslitmus/results.html: -------------------------------------------------------------------------------- 1 | 3 | 4 | 5 | 6 | Benchmark results 7 | 25 | 26 | 27 |
        28 | 29 | 30 | 31 |
        SHA1 ff8311be…
        32 |
        Sun Nov 01 07:27:44 -0500 2009 33 | getById speed improvement in IE6 34 | 35 | 36 |
        37 | 38 |
        SHA1 8a27146a…
        39 |
        Wed Nov 04 21:57:21 -0500 2009 40 | speed improvement from absorbing getByTag into match:selector 41 | 42 |
        43 | 44 |
        SHA1 2363dd60…
        45 |
        Wed Nov 04 23:04:07 -0500 2009 46 | 47 | 48 |
        49 | 50 |
        SHA1 41765d28
        51 |
        Mon Jan 18 15:24:40 -0500 2010 52 | 53 | 54 | 55 |
        In IE Sizzle is returning too many for results. Containing closed nodes and comments? 56 |
        57 | 58 | 65 | 66 |
        67 | 68 | 69 | -------------------------------------------------------------------------------- /speed/jslitmus/bench_parse.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Parse benchmarks 6 | 7 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 21 | 22 | 23 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 116 | 127 | 128 | 129 | 130 |
        131 | 137 |
        138 | 145 |

        146 |
        147 |
        148 | 149 | 150 | 151 | 152 | 155 | 156 |
        157 | 158 |

        Slick Developer Benchmarks for pre-release Slick

        159 | 160 | 161 | 162 | -------------------------------------------------------------------------------- /speed/subtleslickspeed/lib/subtlesandbox.js: -------------------------------------------------------------------------------- 1 | /* 2 | SubtleSandbox 3 | Copyright 2009 Thomas Aylott (subtleGradient.com) 4 | MIT License 5 | 6 | Some code taken from/inspired by MooTools 7 | */ 8 | var SubtleSandbox = (function(){ 9 | 10 | function SubtleSandbox(name,mode){ 11 | this.name = name; 12 | this.window = SubtleSandbox.makeIframe.call(this, name, mode); 13 | this.registeredScripts = {}; 14 | }; 15 | SubtleSandbox.prototype = Object.merge( 16 | Events, 17 | { 18 | loadScript: function(url){ 19 | SubtleSandbox.loadScript(url, this.window, this); 20 | return this; 21 | }, 22 | registerScript: function(scriptName, object){ 23 | if (scriptName=='eval' && object.eval) { 24 | this.eval = object.eval.eval; 25 | this.fireEventStatic('load'); 26 | return this; 27 | } 28 | this.registeredScripts[scriptName] = object; 29 | this.fireEventStatic('load'); 30 | this.fireEventStatic('load:'+scriptName); 31 | WindowEvents.fireEvent('load:'+scriptName); 32 | return this; 33 | } 34 | } 35 | ); 36 | 37 | SubtleSandbox.sandboxes = {}; 38 | 39 | SubtleSandbox.makeIframe = 40 | function makeIframe(name,mode){ 41 | /* console.log('makeIframe'); */ 42 | var thisSandbox = SubtleSandbox.sandboxes[name] = this; 43 | this.mode = mode || 'quirks'; 44 | 45 | var iframe = document.createElement("iframe"); 46 | iframe.style.display = "none"; 47 | iframe.src = getSrc(this.mode) + (this.mode=='quirks')?'': '?' + name; 48 | 49 | document.body.appendChild(iframe); 50 | 51 | thisSandbox.iframe = iframe; 52 | thisSandbox.window = frames[frames.length - 1]; 53 | 54 | if (this.mode === 'quirks'){ 55 | thisSandbox.window.document.write( 56 | "\ 57 | var MSIE/*@cc_on =1@*/;\ 58 | SubtleSandboxed = function(scriptName,object){\ 59 | parent.SubtleSandbox.sandboxes[\""+ name +"\"].registerScript(scriptName, object);\ 60 | };\ 61 | SubtleSandboxed('eval',{ 'eval': MSIE ? this : { eval:function(s){return eval(s)} } });\ 62 | <\/script>" 63 | ); 64 | thisSandbox.window.document.title = "SubtleSandbox Quirks"; 65 | thisSandbox.window.document.close(); 66 | } 67 | return thisSandbox.window; 68 | }; 69 | function getSrc(mode){ 70 | if (mode == 'quirks') return 'javascript:false;'; 71 | 72 | var scripts = document.getElementsByTagName('script'); 73 | var scriptBaseURL; 74 | for (var i = scripts.length - 1, re=/subtlesandbox/; i >= 0; i--){ 75 | if (re.test(scripts[i].src)){ 76 | scriptBaseURL = scripts[i].src.split(re)[0]; 77 | break; 78 | } 79 | if (i === 0) scriptBaseURL = scripts[i].src.split(/\w+\.js/)[0]; 80 | } 81 | return scriptBaseURL + "subtlesandbox_"+mode+".html"; 82 | }; 83 | 84 | 85 | SubtleSandbox.loadScript = function(urls, win, sandbox){ 86 | sandbox = sandbox || WindowEvents; 87 | sandbox.addEvent('load',function(){ 88 | loadScript(urls, win, sandbox); 89 | }); 90 | }; 91 | function loadScript(urls, win, sandbox){ 92 | if (!urls) return; 93 | // console.log('< SubtleSandbox.loadScript', urls); 94 | 95 | urls = $splat(urls); 96 | var url = urls[0]; 97 | urls = urls.slice(1); 98 | 99 | win = win || window; 100 | 101 | // FIXME: This won't support Safari 2 without checking for load manually 102 | var events = { 103 | load: function() { 104 | // console.log('<<< SubtleSandbox.loadScript:load', url); 105 | SubtleEventsJr.remove(script, 'load', events.load); 106 | SubtleEventsJr.remove(script, 'readystatechange', events.readystatechange); 107 | sandbox.fireEventStatic('load:'+ url); 108 | WindowEvents.fireEvent('load:'+ url); 109 | if (urls.length) SubtleSandbox.loadScript(urls, win, sandbox); 110 | }, 111 | readystatechange: function() { 112 | // console.log('readystatechange', url, script.readyState); 113 | if (ScriptLoadStates[script.readyState]) events.load(); 114 | } 115 | }; 116 | 117 | var script = win.document.createElement('script'); 118 | if (sandbox.mode == 'strict' && !(/^(https:|\/)/).test(url)) url = '../' + url; 119 | script.src = url + '?' + Math.random(); 120 | script.onload = events.load; 121 | SubtleEventsJr.add(script, 'load', events.load); 122 | SubtleEventsJr.add(script, 'readystatechange', events.readystatechange); 123 | 124 | sandbox.addEvent('load', function(){ 125 | win.document.body.appendChild(script); 126 | }); 127 | 128 | /* console.log('> SubtleSandbox.loadScript', url); */ 129 | }; 130 | var ScriptLoadStates = { 'loaded':1, 'complete':1 }; 131 | 132 | Object.each(Events,function(fn, key){ SubtleSandbox[key] = function(){ return fn.apply(SubtleSandbox, Array.prototype.slice.call(arguments)); }; }); 133 | 134 | window.SubtleSandboxed = function(scriptName,object){ 135 | SubtleSandbox.registeredScripts = SubtleSandbox.registeredScripts || {}; 136 | SubtleSandbox.registeredScripts[scriptName] = object; 137 | WindowEvents.fireEvent('load:'+scriptName); 138 | }; 139 | 140 | return SubtleSandbox; 141 | })(); 142 | 143 | /* INFO: 144 | 145 | * loadScript is asynchronous 146 | you can't be sure yours loadScripts have fired 147 | unless you write defensive code in your evals or 148 | use `SubtleSandboxed()` in your scripts to register them your sandbox 149 | 150 | The original goal of this thing was to make it easy to create a custom slickspeed. 151 | Load each jslib into its own iframe with its own tests. Then let the tests inform the main js runner that it's ready to go. 152 | 153 | */ 154 | 155 | /* USAGE: 156 | 157 | var mySandbox = new SubtleSandbox('mySandbox'); 158 | mySandbox.loadScript('url_to_file.js'); 159 | mySandbox.eval('doSomething();'); 160 | 161 | // In `url_to_file.js` 162 | 163 | SubtleSandboxed({ 164 | 'test1': function(){} 165 | }); 166 | 167 | */ 168 | 169 | /* TODO: 170 | TODO: flesh out the registerScript functionality 171 | TODO: allow some sort of delayedEval that fires once the registerScript has loaded and fires a callback? 172 | TODO: integrate jslib Events? 173 | 174 | */ 175 | --------------------------------------------------------------------------------