├── _config.yml ├── .gitignore ├── coverage ├── lcov-report │ ├── sort-arrow-sprite.png │ ├── prettify.css │ ├── index.html │ ├── cjs │ │ ├── index.html │ │ └── index.js.html │ ├── sorter.js │ ├── base.css │ └── prettify.js ├── lcov.info └── coverage.json ├── .travis.yml ├── .npmignore ├── test ├── ubl.js ├── browser.js ├── index.js └── index.html ├── rollup.config.js ├── LICENSE ├── package.json ├── base.html ├── min.js ├── README.md ├── esm └── index.js ├── cjs └── index.js └── index.js /_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-architect -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | .DS_Store 2 | node_modules/ 3 | package-lock.json -------------------------------------------------------------------------------- /coverage/lcov-report/sort-arrow-sprite.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/WebReflection/query-result/HEAD/coverage/lcov-report/sort-arrow-sprite.png -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | node_js: 3 | - stable 4 | git: 5 | depth: 1 6 | branches: 7 | only: 8 | - master 9 | after_success: 10 | - "npm run coveralls" -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | coverage/* 2 | node_modules/* 3 | test/* 4 | _config.yml 5 | .DS_Store 6 | .gitignore 7 | .npmignore 8 | .travis.yml 9 | base.html 10 | package-lock.json 11 | rollup.config.js 12 | -------------------------------------------------------------------------------- /test/ubl.js: -------------------------------------------------------------------------------- 1 | // https://github.com/WebReflection/ubl 2 | (function(g,d,s){if(!g.ESM){ 3 | s=d.documentElement;s=s.insertBefore(d.createElement('script'),s.lastChild); 4 | s.defer=!0;s.type='text/javascript';s.src='../min.js'; 5 | }}(window,document)); 6 | -------------------------------------------------------------------------------- /rollup.config.js: -------------------------------------------------------------------------------- 1 | import babel from 'rollup-plugin-babel'; 2 | 3 | export default { 4 | input: 'esm/index.js', 5 | output: { 6 | file: 'index.js', 7 | format: 'iife', 8 | name: '$' 9 | }, 10 | plugins: [ 11 | babel({ 12 | babelrc: false, 13 | presets: ['@babel/preset-env'] 14 | }) 15 | ] 16 | }; -------------------------------------------------------------------------------- /test/browser.js: -------------------------------------------------------------------------------- 1 | if (!console.assert) 2 | console.assert = console.log; 3 | $(function (event) { 4 | console.assert(!!event, 'ready triggered'); 5 | $(function () { 6 | var children = $('p'); 7 | console.assert(children.length === 2, 'qSA works'); 8 | console.assert($(children).length === 2, 'qr works'); 9 | console.assert($('p:first,a:first').length === 1, 'qS works'); 10 | console.assert(children instanceof $, 'instanceof works'); 11 | console.assert(children.map(Object) instanceof $, 'map works'); 12 | $('html')[0].style.background = '#55FF99'; 13 | $('body')[0].textContent = 'OK'; 14 | }); 15 | }); -------------------------------------------------------------------------------- /coverage/lcov-report/prettify.css: -------------------------------------------------------------------------------- 1 | .pln{color:#000}@media screen{.str{color:#080}.kwd{color:#008}.com{color:#800}.typ{color:#606}.lit{color:#066}.pun,.opn,.clo{color:#660}.tag{color:#008}.atn{color:#606}.atv{color:#080}.dec,.var{color:#606}.fun{color:red}}@media print,projection{.str{color:#060}.kwd{color:#006;font-weight:bold}.com{color:#600;font-style:italic}.typ{color:#404;font-weight:bold}.lit{color:#044}.pun,.opn,.clo{color:#440}.tag{color:#006;font-weight:bold}.atn{color:#404}.atv{color:#060}}pre.prettyprint{padding:2px;border:1px solid #888}ol.linenums{margin-top:0;margin-bottom:0}li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8{list-style-type:none}li.L1,li.L3,li.L5,li.L7,li.L9{background:#eee} 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | ISC License 2 | 3 | Copyright (c) 2018, Andrea Giammarchi, @WebReflection 4 | 5 | Permission to use, copy, modify, and/or distribute this software for any 6 | purpose with or without fee is hereby granted, provided that the above 7 | copyright notice and this permission notice appear in all copies. 8 | 9 | THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 10 | REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 11 | AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 12 | INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 13 | LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 14 | OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 15 | PERFORMANCE OF THIS SOFTWARE. 16 | -------------------------------------------------------------------------------- /test/index.js: -------------------------------------------------------------------------------- 1 | const tressa = require('tressa'); 2 | const {CustomEvent, Document} = require('basicHTML'); 3 | 4 | global.CustomEvent = CustomEvent; 5 | global.document = new Document; 6 | 7 | global.postMessage = function () {}; 8 | global.addEventListener = global.postMessage; 9 | global.removeEventListener = global.postMessage; 10 | 11 | const $ = require('../cjs/index.js').default; 12 | 13 | document.body.innerHTML = '

1

2

'; 14 | document.readyState = 'loading'; 15 | 16 | tressa.title('query-result'); 17 | 18 | $(event => { 19 | tressa.assert(!!event, 'ready triggered'); 20 | document.readyState = 'whatever'; 21 | document.documentElement.doScroll = false; 22 | $(() => { 23 | const children = $('p'); 24 | tressa.assert(children.length === 2, 'qSA works'); 25 | tressa.assert($(children).length === 2, 'qr works'); 26 | tressa.assert($('p:first,a:first').length === 1, 'qS works'); 27 | tressa.assert(children instanceof $, 'instanceof works'); 28 | tressa.assert(children.map(Object) instanceof $, 'map works'); 29 | }); 30 | }); 31 | 32 | $(document).dispatch('DOMContentLoaded'); 33 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "1.0.5", 3 | "license": "ISC", 4 | "name": "query-result", 5 | "description": "Rethinking the $", 6 | "homepage": "https://github.com/WebReflection/query-result", 7 | "keywords": [ 8 | "$", 9 | "jQuery", 10 | "Zepto", 11 | "like", 12 | "light", 13 | "modern", 14 | "utility", 15 | "DOM" 16 | ], 17 | "author": { 18 | "name": "Andrea Giammarchi", 19 | "web": "http://webreflection.blogspot.com/" 20 | }, 21 | "repository": { 22 | "type": "git", 23 | "url": "git://github.com/WebReflection/query-result.git" 24 | }, 25 | "main": "cjs/index.js", 26 | "module": "esm/index.js", 27 | "unpkg": "min.js", 28 | "scripts": { 29 | "build": "npm run cjs && npm run max && npm run min && npm run size && npm run test", 30 | "cjs": "ascjs esm cjs", 31 | "coveralls": "cat ./coverage/lcov.info | coveralls", 32 | "max": "rollup -c", 33 | "min": "echo '/*! (c) Andrea Giammarchi - ISC */'>tmp.js && cat index.js >> tmp.js && uglifyjs tmp.js --support-ie8 --comments=/^!/ -c -m -o min.js && rm tmp.js", 34 | "size": "cat min.js | wc -c;gzip -c9 min.js | wc -c;cat min.js | brotli | wc -c && rm -f min.js.br", 35 | "test": "istanbul cover test/index.js" 36 | }, 37 | "devDependencies": { 38 | "@babel/core": "^7.1.0", 39 | "@babel/preset-env": "^7.1.0", 40 | "ascjs": "^2.5.1", 41 | "basichtml": "^0.19.0", 42 | "istanbul": "^0.4.5", 43 | "rollup": "^0.66.2", 44 | "rollup-plugin-babel": "^4.0.3", 45 | "tressa": "^0.3.1", 46 | "uglify-js": "^2.8.29" 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /test/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Your Web Page Title 5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 24 | 25 | 30 | 31 | 39 | 40 | 41 |

1

2

42 | 43 | -------------------------------------------------------------------------------- /coverage/lcov.info: -------------------------------------------------------------------------------- 1 | TN: 2 | SF:/Users/agiammarchi/git/query-result/cjs/index.js 3 | FN:33,(anonymous_1) 4 | FN:76,$ 5 | FN:88,(anonymous_3) 6 | FN:105,dispatch 7 | FN:112,off 8 | FN:118,on 9 | FNF:6 10 | FNH:6 11 | FNDA:0,(anonymous_1) 12 | FNDA:10,$ 13 | FNDA:2,(anonymous_3) 14 | FNDA:2,dispatch 15 | FNDA:4,off 16 | FNDA:4,on 17 | DA:20,1 18 | DA:21,1 19 | DA:22,1 20 | DA:23,1 21 | DA:24,1 22 | DA:25,1 23 | DA:28,1 24 | DA:29,1 25 | DA:30,1 26 | DA:31,1 27 | DA:32,1 28 | DA:33,1 29 | DA:34,1 30 | DA:35,1 31 | DA:38,1 32 | DA:41,1 33 | DA:42,15 34 | DA:45,1 35 | DA:46,1 36 | DA:47,1 37 | DA:49,1 38 | DA:50,1 39 | DA:51,2 40 | DA:52,2 41 | DA:53,2 42 | DA:54,3 43 | DA:55,3 44 | DA:56,2 45 | DA:57,2 46 | DA:59,1 47 | DA:61,2 48 | DA:63,1 49 | DA:68,1 50 | DA:69,1 51 | DA:70,1 52 | DA:71,1 53 | DA:72,1 54 | DA:76,1 55 | DA:77,10 56 | DA:78,2 57 | DA:81,6 58 | DA:82,6 59 | DA:83,6 60 | DA:84,6 61 | DA:86,2 62 | DA:87,2 63 | DA:88,2 64 | DA:89,2 65 | DA:90,2 66 | DA:91,2 67 | DA:93,2 68 | DA:94,2 69 | DA:95,2 70 | DA:96,2 71 | DA:97,1 72 | DA:98,2 73 | DA:101,1 74 | DA:102,1 75 | DA:103,3 76 | DA:105,1 77 | DA:106,2 78 | DA:107,2 79 | DA:108,2 80 | DA:109,2 81 | DA:110,2 82 | DA:113,4 83 | DA:114,4 84 | DA:115,4 85 | DA:116,4 86 | DA:119,4 87 | DA:120,4 88 | DA:121,4 89 | DA:122,4 90 | DA:125,1 91 | LF:74 92 | LH:74 93 | BRDA:28,1,0,0 94 | BRDA:28,1,1,1 95 | BRDA:31,2,0,0 96 | BRDA:31,2,1,0 97 | BRDA:35,3,0,0 98 | BRDA:35,3,1,0 99 | BRDA:41,4,0,1 100 | BRDA:41,4,1,0 101 | BRDA:55,5,0,2 102 | BRDA:55,5,1,1 103 | BRDA:57,6,0,1 104 | BRDA:57,6,1,1 105 | BRDA:63,7,0,1 106 | BRDA:63,7,1,0 107 | BRDA:77,8,0,2 108 | BRDA:77,8,1,6 109 | BRDA:77,8,2,2 110 | BRDA:82,9,0,5 111 | BRDA:82,9,1,1 112 | BRDA:82,10,0,6 113 | BRDA:82,10,1,3 114 | BRDA:96,11,0,1 115 | BRDA:96,11,1,1 116 | BRDA:96,12,0,2 117 | BRDA:96,12,1,2 118 | BRDA:96,12,2,1 119 | BRF:26 120 | BRH:26 121 | end_of_record 122 | -------------------------------------------------------------------------------- /base.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Your Web Page Title 5 | 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 37 | 38 | 39 | 40 | 41 | 43 | 44 | 45 | 46 | 47 | -------------------------------------------------------------------------------- /min.js: -------------------------------------------------------------------------------- 1 | /*! (c) Andrea Giammarchi - ISC */ 2 | var $=function(){"use strict";function t(e){return(t="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t})(e)}function e(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}function n(t,e){if("function"!=typeof e&&null!==e)throw new TypeError("Super expression must either be null or a function");t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&o(t,e)}function r(t){return(r=Object.setPrototypeOf?Object.getPrototypeOf:function(t){return t.__proto__||Object.getPrototypeOf(t)})(t)}function o(t,e){return(o=Object.setPrototypeOf||function(t,e){return t.__proto__=e,t})(t,e)}function u(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],function(){})),!0}catch(t){return!1}}function i(t,e,n){return i=u()?Reflect.construct:function(t,e,n){var r=[null];r.push.apply(r,e);var u=Function.bind.apply(t,r),i=new u;return n&&o(i,n.prototype),i},i.apply(null,arguments)}function c(t){return-1!==Function.toString.call(t).indexOf("[native code]")}function f(t){var e="function"==typeof Map?new Map:undefined;return(f=function(t){function n(){return i(t,arguments,r(this).constructor)}if(null===t||!c(t))return t;if("function"!=typeof t)throw new TypeError("Super expression must either be null or a function");if(void 0!==e){if(e.has(t))return e.get(t);e.set(t,n)}return n.prototype=Object.create(t.prototype,{constructor:{value:n,enumerable:!1,writable:!0,configurable:!0}}),o(n,t)})(t)}function a(t){if(void 0===t)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return t}function l(t,e){return!e||"object"!=typeof e&&"function"!=typeof e?a(t):e}var p=function(t){function o(){return e(this,o),l(this,r(o).apply(this,arguments))}return n(o,t),o}(f(Array)),s=Object.create,y=Object.defineProperty,d=Array.prototype,h=new p instanceof p,v=p.prototype;h||Object.getOwnPropertyNames(d).forEach(function(t){var e=Object.getOwnPropertyDescriptor(d,t);if("function"==typeof e.value){var n=e.value;e.value=function(){var t=n.apply(this,arguments);return t instanceof Array?b(t):t}}y(v,t,e)});var b=h?function(t){return t}:function(t){var e=s(v);return g.apply(e,O(t)),e},g=d.push,m=function(t,e){for(var n=[],r=t.length,o=0;o1&&arguments[1]!==undefined?arguments[1]:document;switch(t(e)){case"string":return b(m(e.split(","),n));case"object":var r=[],o="nodeType"in e||"postMessage"in e?[e]:e;return g.apply(r,O(o)),b(i(p,r));case"function":var u=S(n),c=S(n.defaultView),f={handleEvent:function(t){u.off("DOMContentLoaded",f),c.off("load",f),e(t)}};u.on("DOMContentLoaded",f),c.on("load",f);var a=n.readyState;return("complete"==a||"loading"!=a&&!n.documentElement.doScroll)&&setTimeout(function(){return u.dispatch("DOMContentLoaded")}),S}};return w.prototype=v,w.extend=function(t,e){return y(v,t,{configurable:!0,value:e}),w},w.extend("dispatch",function(t){for(var e=arguments.length>1&&arguments[1]!==undefined?arguments[1]:{},n=new CustomEvent(t,e),r=this.length,o=0;o2&&arguments[2]!==undefined&&arguments[2],r=this.length,o=0;o2&&arguments[2]!==undefined&&arguments[2],r=this.length,o=0;o 2 | 3 | 4 | Code coverage report for All files 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | / 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 76/76 26 |
27 |
28 | 100% 29 | Branches 30 | 26/26 31 |
32 |
33 | 100% 34 | Functions 35 | 6/6 36 |
37 |
38 | 100% 39 | Lines 40 | 74/74 41 |
42 |
43 | 16 statements, 1 function, 7 branches 44 | Ignored      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 | 74 | 75 | 76 | 77 | 78 | 79 |
FileStatementsBranchesFunctionsLines
cjs/
100%76/76100%26/26100%6/6100%74/74
80 |
81 |
82 | 86 | 87 | 88 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | QueryResult, rethinking the `$()` 2 | ================================= 3 | 4 | [![Build Status](https://travis-ci.org/WebReflection/query-result.svg?branch=master)](https://travis-ci.org/WebReflection/query-result) [![Coverage Status](https://coveralls.io/repos/github/WebReflection/query-result/badge.svg?branch=master)](https://coveralls.io/github/WebReflection/query-result?branch=master) 5 | 6 | ### In a nutshell 7 | 8 | This model is a modern, minimal, 60LOC (esm) based version of a jQuery(_ish_) utility. 9 | 10 | #### Features: 11 | 12 | * `$(readyFunction)` to run code when document is ready 13 | * `$(CSS, optionalParent)` to return a collection of elements 14 | * `$(document || window)` to use methods with these globals 15 | * `$(anyArrayLike)` to transform a collection into a `QueryResult` instance 16 | * `any instanceof $` to know if an object implements all `QueryResult` methods 17 | * `$.extend(name, function () { ... })` to pollute the `QueryResult` prototype 18 | * `$(...).on(type, handler, options)` to add listeners to all entries 19 | * `$(...).off(type, handler, options)` to remove listeners from all entries 20 | * `$(...).dispatch(type, initDictionary)` to dispatch a `CustomEvent` to all entries 21 | 22 | Everything else can be added via `$.extend(methodName, function () {})`, 23 | remembering that arrow functions aren't a good idea if you need a context too. 24 | 25 | ```js 26 | // ready equivalent $(ready) 27 | $(event => { 28 | $('input[required]') 29 | // regular Array methods available 30 | .filter(el => !el.value.trim()) 31 | // add a specific class to the filtered list 32 | .map(el => { 33 | el.classList.add('please-fill-me'); 34 | return el; 35 | }) 36 | // still on an instance of QueryResult 37 | // so we could add a listener to each element 38 | .on('focus', el => el.classList.remove('please-fill-me')) 39 | // with chainability included 40 | .on('blur', el => { 41 | if (!el.value.trim()) 42 | el.classList.add('please-fill-me'); 43 | }); 44 | }); 45 | ``` 46 | 47 | #### :first 48 | If a string contains the pseudo selector `:first` at its end, 49 | the result will stop at the very first encountered match. 50 | 51 | This is the only non-standard pseudo-selector implemented. 52 | ```js 53 | // will return only first matched p 54 | // and the first matched span 55 | $('p:first, span:first') 56 | ``` 57 | This is especially handy in term of performance since 58 | the browser will actually stop searching instead of analyzing 59 | the entire document (using `querySelector` instead of `querySelectorAll`). 60 | 61 | ### Examples 62 | 63 | ```js 64 | // add a listener 65 | $('a:first').on('click', function(e) { 66 | e.preventDefault(); 67 | alert(e.detail); 68 | }); 69 | 70 | // dispatch an event 71 | $('a:first').dispatch( 72 | 'click', 73 | // optional CustomEvent dictionary 74 | {detail: 'Hello there!'} 75 | ); 76 | 77 | // using Array methods 78 | var newCollection = $('.new-nodes') 79 | .concat(previousCollection) 80 | .filter(because) 81 | .on('custom:event', react); 82 | 83 | 84 | // extending via method 85 | $.extend('html', function (html) { 86 | var el = (this[0] || {}); 87 | if (html) el.innerHTML = html; 88 | else return el.innerHTML; 89 | }); 90 | 91 | 92 | // extending via descriptor 93 | $.extend('html', { 94 | get () { 95 | return this[0] && this[0].innerHTML; 96 | }, 97 | set (html) { 98 | if (this.length) { 99 | this[0].innerHTML = html; 100 | } 101 | } 102 | }); 103 | 104 | ``` 105 | 106 | ### Compatibility 107 | You can verify by yourself through [this page](http://webreflection.github.io/query-result/test/) but it should work down to very old browsers. 108 | 109 | ### How to include 110 | 111 | * `import $ from 'query-result'` for ESM (`query-result/esm/index.js` explicitly) 112 | * `const $ = require('query-result/cjs')` for CJS 113 | * `` for browsers as global `$` 114 | -------------------------------------------------------------------------------- /coverage/lcov-report/cjs/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for cjs/ 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files cjs/ 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 76/76 26 |
27 |
28 | 100% 29 | Branches 30 | 26/26 31 |
32 |
33 | 100% 34 | Functions 35 | 6/6 36 |
37 |
38 | 100% 39 | Lines 40 | 74/74 41 |
42 |
43 | 16 statements, 1 function, 7 branches 44 | Ignored      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 | 74 | 75 | 76 | 77 | 78 | 79 |
FileStatementsBranchesFunctionsLines
index.js
100%76/76100%26/26100%6/6100%74/74
80 |
81 |
82 | 86 | 87 | 88 | 95 | 96 | 97 | 98 | -------------------------------------------------------------------------------- /esm/index.js: -------------------------------------------------------------------------------- 1 | /** 2 | * ISC License 3 | * 4 | * Copyright (c) 2018, Andrea Giammarchi, @WebReflection 5 | * 6 | * Permission to use, copy, modify, and/or distribute this software for any 7 | * purpose with or without fee is hereby granted, provided that the above 8 | * copyright notice and this permission notice appear in all copies. 9 | * 10 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 11 | * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 12 | * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 13 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 14 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 15 | * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 16 | * PERFORMANCE OF THIS SOFTWARE. 17 | */ 18 | class QueryResult extends Array {} 19 | const {create, defineProperty} = Object; 20 | const AP = Array.prototype; 21 | const DOM_CONTENT_LOADED = 'DOMContentLoaded'; 22 | const LOAD = 'load'; 23 | const NO_TRANSPILER_ISSUES = (new QueryResult) instanceof QueryResult; 24 | const QRP = QueryResult.prototype; 25 | // fixes methods returning non QueryResult 26 | /* istanbul ignore if */ 27 | if (!NO_TRANSPILER_ISSUES) 28 | Object.getOwnPropertyNames(AP).forEach(name => { 29 | const desc = Object.getOwnPropertyDescriptor(AP, name); 30 | if (typeof desc.value === 'function') { 31 | const fn = desc.value; 32 | desc.value = function () { 33 | const result = fn.apply(this, arguments); 34 | return result instanceof Array ? patch(result) : result; 35 | }; 36 | } 37 | defineProperty(QRP, name, desc); 38 | }); 39 | // fixes badly transpiled classes 40 | const patch = NO_TRANSPILER_ISSUES ? 41 | qr => qr : 42 | /* istanbul ignore next */ 43 | qr => { 44 | const nqr = create(QRP); 45 | push.apply(nqr, slice(qr)); 46 | return nqr; 47 | }; 48 | const push = AP.push; 49 | const search = (list, el) => { 50 | const nodes = []; 51 | const length = list.length; 52 | for (let i = 0; i < length; i++) { 53 | const css = list[i].trim(); 54 | if (css.slice(-6) === ':first') { 55 | const node = el.querySelector(css.slice(0, -6)); 56 | if (node) push.call(nodes, node); 57 | } else 58 | push.apply(nodes, slice(el.querySelectorAll(css))); 59 | } 60 | return new QueryResult(...nodes); 61 | }; 62 | const slice = NO_TRANSPILER_ISSUES ? 63 | patch : 64 | /* istanbul ignore next */ 65 | all => { 66 | // do not use slice.call(...) due old IE gotcha 67 | const nodes = []; 68 | const length = all.length; 69 | for (let i = 0; i < length; i++) 70 | nodes[i] = all[i]; 71 | return nodes; 72 | } 73 | // use function to avoid usage of Symbol.hasInstance 74 | // (broken in older browsers anyway) 75 | const $ = function $(CSS, parent = document) { 76 | switch (typeof CSS) { 77 | case 'string': return patch(search(CSS.split(','), parent)); 78 | case 'object': 79 | // needed to avoid iterator dance (breaks in older IEs) 80 | const nodes = []; 81 | const all = ('nodeType' in CSS || 'postMessage' in CSS) ? [CSS] : CSS; 82 | push.apply(nodes, slice(all)); 83 | return patch(new QueryResult(...nodes)); 84 | case 'function': 85 | const $parent = $(parent); 86 | const $window = $(parent.defaultView); 87 | const handler = {handleEvent(event) { 88 | $parent.off(DOM_CONTENT_LOADED, handler); 89 | $window.off(LOAD, handler); 90 | CSS(event); 91 | }}; 92 | $parent.on(DOM_CONTENT_LOADED, handler); 93 | $window.on(LOAD, handler); 94 | const rs = parent.readyState; 95 | if (rs == 'complete' || (rs != 'loading' && !parent.documentElement.doScroll)) 96 | setTimeout(() => $parent.dispatch(DOM_CONTENT_LOADED)); 97 | return $; 98 | } 99 | }; 100 | $.prototype = QRP; 101 | $.extend = (key, value) => 102 | (defineProperty(QRP, key, {configurable: true, value}), $); 103 | // dropped usage of for-of to avoid broken iteration dance in older IEs 104 | $.extend('dispatch', function dispatch(type, init = {}) { 105 | const event = new CustomEvent(type, init); 106 | const length = this.length; 107 | for (let i = 0; i < length; i++) 108 | this[i].dispatchEvent(event); 109 | return this; 110 | }) 111 | .extend('off', function off(type, handler, options = false) { 112 | const length = this.length; 113 | for (let i = 0; i < length; i++) 114 | this[i].removeEventListener(type, handler, options); 115 | return this; 116 | }) 117 | .extend('on', function on(type, handler, options = false) { 118 | const length = this.length; 119 | for (let i = 0; i < length; i++) 120 | this[i].addEventListener(type, handler, options); 121 | return this; 122 | }); 123 | 124 | export default $; 125 | -------------------------------------------------------------------------------- /cjs/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | /** 3 | * ISC License 4 | * 5 | * Copyright (c) 2018, Andrea Giammarchi, @WebReflection 6 | * 7 | * Permission to use, copy, modify, and/or distribute this software for any 8 | * purpose with or without fee is hereby granted, provided that the above 9 | * copyright notice and this permission notice appear in all copies. 10 | * 11 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 12 | * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 13 | * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 14 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 15 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 16 | * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 17 | * PERFORMANCE OF THIS SOFTWARE. 18 | */ 19 | class QueryResult extends Array {} 20 | const {create, defineProperty} = Object; 21 | const AP = Array.prototype; 22 | const DOM_CONTENT_LOADED = 'DOMContentLoaded'; 23 | const LOAD = 'load'; 24 | const NO_TRANSPILER_ISSUES = (new QueryResult) instanceof QueryResult; 25 | const QRP = QueryResult.prototype; 26 | // fixes methods returning non QueryResult 27 | /* istanbul ignore if */ 28 | if (!NO_TRANSPILER_ISSUES) 29 | Object.getOwnPropertyNames(AP).forEach(name => { 30 | const desc = Object.getOwnPropertyDescriptor(AP, name); 31 | if (typeof desc.value === 'function') { 32 | const fn = desc.value; 33 | desc.value = function () { 34 | const result = fn.apply(this, arguments); 35 | return result instanceof Array ? patch(result) : result; 36 | }; 37 | } 38 | defineProperty(QRP, name, desc); 39 | }); 40 | // fixes badly transpiled classes 41 | const patch = NO_TRANSPILER_ISSUES ? 42 | qr => qr : 43 | /* istanbul ignore next */ 44 | qr => { 45 | const nqr = create(QRP); 46 | push.apply(nqr, slice(qr)); 47 | return nqr; 48 | }; 49 | const push = AP.push; 50 | const search = (list, el) => { 51 | const nodes = []; 52 | const length = list.length; 53 | for (let i = 0; i < length; i++) { 54 | const css = list[i].trim(); 55 | if (css.slice(-6) === ':first') { 56 | const node = el.querySelector(css.slice(0, -6)); 57 | if (node) push.call(nodes, node); 58 | } else 59 | push.apply(nodes, slice(el.querySelectorAll(css))); 60 | } 61 | return new QueryResult(...nodes); 62 | }; 63 | const slice = NO_TRANSPILER_ISSUES ? 64 | patch : 65 | /* istanbul ignore next */ 66 | all => { 67 | // do not use slice.call(...) due old IE gotcha 68 | const nodes = []; 69 | const length = all.length; 70 | for (let i = 0; i < length; i++) 71 | nodes[i] = all[i]; 72 | return nodes; 73 | } 74 | // use function to avoid usage of Symbol.hasInstance 75 | // (broken in older browsers anyway) 76 | const $ = function $(CSS, parent = document) { 77 | switch (typeof CSS) { 78 | case 'string': return patch(search(CSS.split(','), parent)); 79 | case 'object': 80 | // needed to avoid iterator dance (breaks in older IEs) 81 | const nodes = []; 82 | const all = ('nodeType' in CSS || 'postMessage' in CSS) ? [CSS] : CSS; 83 | push.apply(nodes, slice(all)); 84 | return patch(new QueryResult(...nodes)); 85 | case 'function': 86 | const $parent = $(parent); 87 | const $window = $(parent.defaultView); 88 | const handler = {handleEvent(event) { 89 | $parent.off(DOM_CONTENT_LOADED, handler); 90 | $window.off(LOAD, handler); 91 | CSS(event); 92 | }}; 93 | $parent.on(DOM_CONTENT_LOADED, handler); 94 | $window.on(LOAD, handler); 95 | const rs = parent.readyState; 96 | if (rs == 'complete' || (rs != 'loading' && !parent.documentElement.doScroll)) 97 | setTimeout(() => $parent.dispatch(DOM_CONTENT_LOADED)); 98 | return $; 99 | } 100 | }; 101 | $.prototype = QRP; 102 | $.extend = (key, value) => 103 | (defineProperty(QRP, key, {configurable: true, value}), $); 104 | // dropped usage of for-of to avoid broken iteration dance in older IEs 105 | $.extend('dispatch', function dispatch(type, init = {}) { 106 | const event = new CustomEvent(type, init); 107 | const length = this.length; 108 | for (let i = 0; i < length; i++) 109 | this[i].dispatchEvent(event); 110 | return this; 111 | }) 112 | .extend('off', function off(type, handler, options = false) { 113 | const length = this.length; 114 | for (let i = 0; i < length; i++) 115 | this[i].removeEventListener(type, handler, options); 116 | return this; 117 | }) 118 | .extend('on', function on(type, handler, options = false) { 119 | const length = this.length; 120 | for (let i = 0; i < length; i++) 121 | this[i].addEventListener(type, handler, options); 122 | return this; 123 | }); 124 | 125 | Object.defineProperty(exports, '__esModule', {value: true}).default = $; 126 | -------------------------------------------------------------------------------- /coverage/lcov-report/sorter.js: -------------------------------------------------------------------------------- 1 | var addSorting = (function () { 2 | "use strict"; 3 | var cols, 4 | currentSort = { 5 | index: 0, 6 | desc: false 7 | }; 8 | 9 | // returns the summary table element 10 | function getTable() { return document.querySelector('.coverage-summary'); } 11 | // returns the thead element of the summary table 12 | function getTableHeader() { return getTable().querySelector('thead tr'); } 13 | // returns the tbody element of the summary table 14 | function getTableBody() { return getTable().querySelector('tbody'); } 15 | // returns the th element for nth column 16 | function getNthColumn(n) { return getTableHeader().querySelectorAll('th')[n]; } 17 | 18 | // loads all columns 19 | function loadColumns() { 20 | var colNodes = getTableHeader().querySelectorAll('th'), 21 | colNode, 22 | cols = [], 23 | col, 24 | i; 25 | 26 | for (i = 0; i < colNodes.length; i += 1) { 27 | colNode = colNodes[i]; 28 | col = { 29 | key: colNode.getAttribute('data-col'), 30 | sortable: !colNode.getAttribute('data-nosort'), 31 | type: colNode.getAttribute('data-type') || 'string' 32 | }; 33 | cols.push(col); 34 | if (col.sortable) { 35 | col.defaultDescSort = col.type === 'number'; 36 | colNode.innerHTML = colNode.innerHTML + ''; 37 | } 38 | } 39 | return cols; 40 | } 41 | // attaches a data attribute to every tr element with an object 42 | // of data values keyed by column name 43 | function loadRowData(tableRow) { 44 | var tableCols = tableRow.querySelectorAll('td'), 45 | colNode, 46 | col, 47 | data = {}, 48 | i, 49 | val; 50 | for (i = 0; i < tableCols.length; i += 1) { 51 | colNode = tableCols[i]; 52 | col = cols[i]; 53 | val = colNode.getAttribute('data-value'); 54 | if (col.type === 'number') { 55 | val = Number(val); 56 | } 57 | data[col.key] = val; 58 | } 59 | return data; 60 | } 61 | // loads all row data 62 | function loadData() { 63 | var rows = getTableBody().querySelectorAll('tr'), 64 | i; 65 | 66 | for (i = 0; i < rows.length; i += 1) { 67 | rows[i].data = loadRowData(rows[i]); 68 | } 69 | } 70 | // sorts the table using the data for the ith column 71 | function sortByIndex(index, desc) { 72 | var key = cols[index].key, 73 | sorter = function (a, b) { 74 | a = a.data[key]; 75 | b = b.data[key]; 76 | return a < b ? -1 : a > b ? 1 : 0; 77 | }, 78 | finalSorter = sorter, 79 | tableBody = document.querySelector('.coverage-summary tbody'), 80 | rowNodes = tableBody.querySelectorAll('tr'), 81 | rows = [], 82 | i; 83 | 84 | if (desc) { 85 | finalSorter = function (a, b) { 86 | return -1 * sorter(a, b); 87 | }; 88 | } 89 | 90 | for (i = 0; i < rowNodes.length; i += 1) { 91 | rows.push(rowNodes[i]); 92 | tableBody.removeChild(rowNodes[i]); 93 | } 94 | 95 | rows.sort(finalSorter); 96 | 97 | for (i = 0; i < rows.length; i += 1) { 98 | tableBody.appendChild(rows[i]); 99 | } 100 | } 101 | // removes sort indicators for current column being sorted 102 | function removeSortIndicators() { 103 | var col = getNthColumn(currentSort.index), 104 | cls = col.className; 105 | 106 | cls = cls.replace(/ sorted$/, '').replace(/ sorted-desc$/, ''); 107 | col.className = cls; 108 | } 109 | // adds sort indicators for current column being sorted 110 | function addSortIndicators() { 111 | getNthColumn(currentSort.index).className += currentSort.desc ? ' sorted-desc' : ' sorted'; 112 | } 113 | // adds event listeners for all sorter widgets 114 | function enableUI() { 115 | var i, 116 | el, 117 | ithSorter = function ithSorter(i) { 118 | var col = cols[i]; 119 | 120 | return function () { 121 | var desc = col.defaultDescSort; 122 | 123 | if (currentSort.index === i) { 124 | desc = !currentSort.desc; 125 | } 126 | sortByIndex(i, desc); 127 | removeSortIndicators(); 128 | currentSort.index = i; 129 | currentSort.desc = desc; 130 | addSortIndicators(); 131 | }; 132 | }; 133 | for (i =0 ; i < cols.length; i += 1) { 134 | if (cols[i].sortable) { 135 | // add the click event handler on the th so users 136 | // dont have to click on those tiny arrows 137 | el = getNthColumn(i).querySelector('.sorter').parentElement; 138 | if (el.addEventListener) { 139 | el.addEventListener('click', ithSorter(i)); 140 | } else { 141 | el.attachEvent('onclick', ithSorter(i)); 142 | } 143 | } 144 | } 145 | } 146 | // adds sorting functionality to the UI 147 | return function () { 148 | if (!getTable()) { 149 | return; 150 | } 151 | cols = loadColumns(); 152 | loadData(cols); 153 | addSortIndicators(); 154 | enableUI(); 155 | }; 156 | })(); 157 | 158 | window.addEventListener('load', addSorting); 159 | -------------------------------------------------------------------------------- /coverage/lcov-report/base.css: -------------------------------------------------------------------------------- 1 | body, html { 2 | margin:0; padding: 0; 3 | height: 100%; 4 | } 5 | body { 6 | font-family: Helvetica Neue, Helvetica, Arial; 7 | font-size: 14px; 8 | color:#333; 9 | } 10 | .small { font-size: 12px; } 11 | *, *:after, *:before { 12 | -webkit-box-sizing:border-box; 13 | -moz-box-sizing:border-box; 14 | box-sizing:border-box; 15 | } 16 | h1 { font-size: 20px; margin: 0;} 17 | h2 { font-size: 14px; } 18 | pre { 19 | font: 12px/1.4 Consolas, "Liberation Mono", Menlo, Courier, monospace; 20 | margin: 0; 21 | padding: 0; 22 | -moz-tab-size: 2; 23 | -o-tab-size: 2; 24 | tab-size: 2; 25 | } 26 | a { color:#0074D9; text-decoration:none; } 27 | a:hover { text-decoration:underline; } 28 | .strong { font-weight: bold; } 29 | .space-top1 { padding: 10px 0 0 0; } 30 | .pad2y { padding: 20px 0; } 31 | .pad1y { padding: 10px 0; } 32 | .pad2x { padding: 0 20px; } 33 | .pad2 { padding: 20px; } 34 | .pad1 { padding: 10px; } 35 | .space-left2 { padding-left:55px; } 36 | .space-right2 { padding-right:20px; } 37 | .center { text-align:center; } 38 | .clearfix { display:block; } 39 | .clearfix:after { 40 | content:''; 41 | display:block; 42 | height:0; 43 | clear:both; 44 | visibility:hidden; 45 | } 46 | .fl { float: left; } 47 | @media only screen and (max-width:640px) { 48 | .col3 { width:100%; max-width:100%; } 49 | .hide-mobile { display:none!important; } 50 | } 51 | 52 | .quiet { 53 | color: #7f7f7f; 54 | color: rgba(0,0,0,0.5); 55 | } 56 | .quiet a { opacity: 0.7; } 57 | 58 | .fraction { 59 | font-family: Consolas, 'Liberation Mono', Menlo, Courier, monospace; 60 | font-size: 10px; 61 | color: #555; 62 | background: #E8E8E8; 63 | padding: 4px 5px; 64 | border-radius: 3px; 65 | vertical-align: middle; 66 | } 67 | 68 | div.path a:link, div.path a:visited { color: #333; } 69 | table.coverage { 70 | border-collapse: collapse; 71 | margin: 10px 0 0 0; 72 | padding: 0; 73 | } 74 | 75 | table.coverage td { 76 | margin: 0; 77 | padding: 0; 78 | vertical-align: top; 79 | } 80 | table.coverage td.line-count { 81 | text-align: right; 82 | padding: 0 5px 0 20px; 83 | } 84 | table.coverage td.line-coverage { 85 | text-align: right; 86 | padding-right: 10px; 87 | min-width:20px; 88 | } 89 | 90 | table.coverage td span.cline-any { 91 | display: inline-block; 92 | padding: 0 5px; 93 | width: 100%; 94 | } 95 | .missing-if-branch { 96 | display: inline-block; 97 | margin-right: 5px; 98 | border-radius: 3px; 99 | position: relative; 100 | padding: 0 4px; 101 | background: #333; 102 | color: yellow; 103 | } 104 | 105 | .skip-if-branch { 106 | display: none; 107 | margin-right: 10px; 108 | position: relative; 109 | padding: 0 4px; 110 | background: #ccc; 111 | color: white; 112 | } 113 | .missing-if-branch .typ, .skip-if-branch .typ { 114 | color: inherit !important; 115 | } 116 | .coverage-summary { 117 | border-collapse: collapse; 118 | width: 100%; 119 | } 120 | .coverage-summary tr { border-bottom: 1px solid #bbb; } 121 | .keyline-all { border: 1px solid #ddd; } 122 | .coverage-summary td, .coverage-summary th { padding: 10px; } 123 | .coverage-summary tbody { border: 1px solid #bbb; } 124 | .coverage-summary td { border-right: 1px solid #bbb; } 125 | .coverage-summary td:last-child { border-right: none; } 126 | .coverage-summary th { 127 | text-align: left; 128 | font-weight: normal; 129 | white-space: nowrap; 130 | } 131 | .coverage-summary th.file { border-right: none !important; } 132 | .coverage-summary th.pct { } 133 | .coverage-summary th.pic, 134 | .coverage-summary th.abs, 135 | .coverage-summary td.pct, 136 | .coverage-summary td.abs { text-align: right; } 137 | .coverage-summary td.file { white-space: nowrap; } 138 | .coverage-summary td.pic { min-width: 120px !important; } 139 | .coverage-summary tfoot td { } 140 | 141 | .coverage-summary .sorter { 142 | height: 10px; 143 | width: 7px; 144 | display: inline-block; 145 | margin-left: 0.5em; 146 | background: url(sort-arrow-sprite.png) no-repeat scroll 0 0 transparent; 147 | } 148 | .coverage-summary .sorted .sorter { 149 | background-position: 0 -20px; 150 | } 151 | .coverage-summary .sorted-desc .sorter { 152 | background-position: 0 -10px; 153 | } 154 | .status-line { height: 10px; } 155 | /* dark red */ 156 | .red.solid, .status-line.low, .low .cover-fill { background:#C21F39 } 157 | .low .chart { border:1px solid #C21F39 } 158 | /* medium red */ 159 | .cstat-no, .fstat-no, .cbranch-no, .cbranch-no { background:#F6C6CE } 160 | /* light red */ 161 | .low, .cline-no { background:#FCE1E5 } 162 | /* light green */ 163 | .high, .cline-yes { background:rgb(230,245,208) } 164 | /* medium green */ 165 | .cstat-yes { background:rgb(161,215,106) } 166 | /* dark green */ 167 | .status-line.high, .high .cover-fill { background:rgb(77,146,33) } 168 | .high .chart { border:1px solid rgb(77,146,33) } 169 | /* dark yellow (gold) */ 170 | .medium .chart { border:1px solid #f9cd0b; } 171 | .status-line.medium, .medium .cover-fill { background: #f9cd0b; } 172 | /* light yellow */ 173 | .medium { background: #fff4c2; } 174 | /* light gray */ 175 | span.cline-neutral { background: #eaeaea; } 176 | 177 | .cbranch-no { background: yellow !important; color: #111; } 178 | 179 | .cstat-skip { background: #ddd; color: #111; } 180 | .fstat-skip { background: #ddd; color: #111 !important; } 181 | .cbranch-skip { background: #ddd !important; color: #111; } 182 | 183 | 184 | .cover-fill, .cover-empty { 185 | display:inline-block; 186 | height: 12px; 187 | } 188 | .chart { 189 | line-height: 0; 190 | } 191 | .cover-empty { 192 | background: white; 193 | } 194 | .cover-full { 195 | border-right: none !important; 196 | } 197 | pre.prettyprint { 198 | border: none !important; 199 | padding: 0 !important; 200 | margin: 0 !important; 201 | } 202 | .com { color: #999 !important; } 203 | .ignore-none { color: #999; font-weight: normal; } 204 | 205 | .wrapper { 206 | min-height: 100%; 207 | height: auto !important; 208 | height: 100%; 209 | margin: 0 auto -48px; 210 | } 211 | .footer, .push { 212 | height: 48px; 213 | } 214 | -------------------------------------------------------------------------------- /coverage/coverage.json: -------------------------------------------------------------------------------- 1 | {"/Users/agiammarchi/git/query-result/cjs/index.js":{"path":"/Users/agiammarchi/git/query-result/cjs/index.js","s":{"1":1,"2":1,"3":1,"4":1,"5":1,"6":1,"7":1,"8":0,"9":0,"10":0,"11":0,"12":0,"13":0,"14":0,"15":0,"16":1,"17":15,"18":0,"19":0,"20":0,"21":1,"22":1,"23":2,"24":2,"25":2,"26":3,"27":3,"28":2,"29":2,"30":1,"31":1,"32":2,"33":1,"34":0,"35":0,"36":0,"37":0,"38":0,"39":1,"40":10,"41":2,"42":6,"43":6,"44":6,"45":6,"46":2,"47":2,"48":2,"49":2,"50":2,"51":2,"52":2,"53":2,"54":2,"55":2,"56":1,"57":1,"58":2,"59":1,"60":1,"61":3,"62":1,"63":2,"64":2,"65":2,"66":2,"67":2,"68":4,"69":4,"70":4,"71":4,"72":4,"73":4,"74":4,"75":4,"76":1},"b":{"1":[0,1],"2":[0,0],"3":[0,0],"4":[1,0],"5":[2,1],"6":[1,1],"7":[1,0],"8":[2,6,2],"9":[5,1],"10":[6,3],"11":[1,1],"12":[2,2,1]},"f":{"1":0,"2":10,"3":2,"4":2,"5":4,"6":4},"fnMap":{"1":{"name":"(anonymous_1)","line":33,"loc":{"start":{"line":33,"column":19},"end":{"line":33,"column":31}},"skip":true},"2":{"name":"$","line":76,"loc":{"start":{"line":76,"column":10},"end":{"line":76,"column":45}}},"3":{"name":"(anonymous_3)","line":88,"loc":{"start":{"line":88,"column":34},"end":{"line":88,"column":42}}},"4":{"name":"dispatch","line":105,"loc":{"start":{"line":105,"column":21},"end":{"line":105,"column":56}}},"5":{"name":"off","line":112,"loc":{"start":{"line":112,"column":15},"end":{"line":112,"column":60}}},"6":{"name":"on","line":118,"loc":{"start":{"line":118,"column":14},"end":{"line":118,"column":58}}}},"statementMap":{"1":{"start":{"line":20,"column":0},"end":{"line":20,"column":40}},"2":{"start":{"line":21,"column":0},"end":{"line":21,"column":27}},"3":{"start":{"line":22,"column":0},"end":{"line":22,"column":46}},"4":{"start":{"line":23,"column":0},"end":{"line":23,"column":20}},"5":{"start":{"line":24,"column":0},"end":{"line":24,"column":70}},"6":{"start":{"line":25,"column":0},"end":{"line":25,"column":34}},"7":{"start":{"line":28,"column":0},"end":{"line":39,"column":5}},"8":{"start":{"line":29,"column":2},"end":{"line":39,"column":5},"skip":true},"9":{"start":{"line":30,"column":4},"end":{"line":30,"column":59},"skip":true},"10":{"start":{"line":31,"column":4},"end":{"line":37,"column":5},"skip":true},"11":{"start":{"line":32,"column":6},"end":{"line":32,"column":28},"skip":true},"12":{"start":{"line":33,"column":6},"end":{"line":36,"column":8},"skip":true},"13":{"start":{"line":34,"column":8},"end":{"line":34,"column":49},"skip":true},"14":{"start":{"line":35,"column":8},"end":{"line":35,"column":64},"skip":true},"15":{"start":{"line":38,"column":4},"end":{"line":38,"column":36},"skip":true},"16":{"start":{"line":41,"column":0},"end":{"line":48,"column":4}},"17":{"start":{"line":42,"column":8},"end":{"line":42,"column":10}},"18":{"start":{"line":45,"column":4},"end":{"line":45,"column":28},"skip":true},"19":{"start":{"line":46,"column":4},"end":{"line":46,"column":31},"skip":true},"20":{"start":{"line":47,"column":4},"end":{"line":47,"column":15},"skip":true},"21":{"start":{"line":49,"column":0},"end":{"line":49,"column":21}},"22":{"start":{"line":50,"column":0},"end":{"line":62,"column":2}},"23":{"start":{"line":51,"column":2},"end":{"line":51,"column":19}},"24":{"start":{"line":52,"column":2},"end":{"line":52,"column":29}},"25":{"start":{"line":53,"column":2},"end":{"line":60,"column":3}},"26":{"start":{"line":54,"column":4},"end":{"line":54,"column":31}},"27":{"start":{"line":55,"column":4},"end":{"line":59,"column":57}},"28":{"start":{"line":56,"column":6},"end":{"line":56,"column":54}},"29":{"start":{"line":57,"column":6},"end":{"line":57,"column":39}},"30":{"start":{"line":57,"column":16},"end":{"line":57,"column":39}},"31":{"start":{"line":59,"column":6},"end":{"line":59,"column":57}},"32":{"start":{"line":61,"column":2},"end":{"line":61,"column":35}},"33":{"start":{"line":63,"column":0},"end":{"line":73,"column":3}},"34":{"start":{"line":68,"column":4},"end":{"line":68,"column":21},"skip":true},"35":{"start":{"line":69,"column":4},"end":{"line":69,"column":30},"skip":true},"36":{"start":{"line":70,"column":4},"end":{"line":71,"column":24},"skip":true},"37":{"start":{"line":71,"column":6},"end":{"line":71,"column":24},"skip":true},"38":{"start":{"line":72,"column":4},"end":{"line":72,"column":17},"skip":true},"39":{"start":{"line":76,"column":0},"end":{"line":100,"column":2}},"40":{"start":{"line":77,"column":2},"end":{"line":99,"column":3}},"41":{"start":{"line":78,"column":19},"end":{"line":78,"column":64}},"42":{"start":{"line":81,"column":6},"end":{"line":81,"column":23}},"43":{"start":{"line":82,"column":6},"end":{"line":82,"column":76}},"44":{"start":{"line":83,"column":6},"end":{"line":83,"column":36}},"45":{"start":{"line":84,"column":6},"end":{"line":84,"column":46}},"46":{"start":{"line":86,"column":6},"end":{"line":86,"column":32}},"47":{"start":{"line":87,"column":6},"end":{"line":87,"column":44}},"48":{"start":{"line":88,"column":6},"end":{"line":92,"column":9}},"49":{"start":{"line":89,"column":8},"end":{"line":89,"column":49}},"50":{"start":{"line":90,"column":8},"end":{"line":90,"column":35}},"51":{"start":{"line":91,"column":8},"end":{"line":91,"column":19}},"52":{"start":{"line":93,"column":6},"end":{"line":93,"column":46}},"53":{"start":{"line":94,"column":6},"end":{"line":94,"column":32}},"54":{"start":{"line":95,"column":6},"end":{"line":95,"column":35}},"55":{"start":{"line":96,"column":6},"end":{"line":97,"column":63}},"56":{"start":{"line":97,"column":8},"end":{"line":97,"column":63}},"57":{"start":{"line":97,"column":25},"end":{"line":97,"column":61}},"58":{"start":{"line":98,"column":6},"end":{"line":98,"column":15}},"59":{"start":{"line":101,"column":0},"end":{"line":101,"column":18}},"60":{"start":{"line":102,"column":0},"end":{"line":103,"column":71}},"61":{"start":{"line":103,"column":13},"end":{"line":103,"column":69}},"62":{"start":{"line":105,"column":0},"end":{"line":123,"column":3}},"63":{"start":{"line":106,"column":2},"end":{"line":106,"column":44}},"64":{"start":{"line":107,"column":2},"end":{"line":107,"column":29}},"65":{"start":{"line":108,"column":2},"end":{"line":109,"column":33}},"66":{"start":{"line":109,"column":4},"end":{"line":109,"column":33}},"67":{"start":{"line":110,"column":2},"end":{"line":110,"column":14}},"68":{"start":{"line":113,"column":2},"end":{"line":113,"column":29}},"69":{"start":{"line":114,"column":2},"end":{"line":115,"column":56}},"70":{"start":{"line":115,"column":4},"end":{"line":115,"column":56}},"71":{"start":{"line":116,"column":2},"end":{"line":116,"column":14}},"72":{"start":{"line":119,"column":2},"end":{"line":119,"column":29}},"73":{"start":{"line":120,"column":2},"end":{"line":121,"column":53}},"74":{"start":{"line":121,"column":4},"end":{"line":121,"column":53}},"75":{"start":{"line":122,"column":2},"end":{"line":122,"column":14}},"76":{"start":{"line":125,"column":0},"end":{"line":125,"column":72}}},"branchMap":{"1":{"line":28,"type":"if","locations":[{"start":{"line":28,"column":0},"end":{"line":28,"column":0},"skip":true},{"start":{"line":28,"column":0},"end":{"line":28,"column":0}}]},"2":{"line":31,"type":"if","locations":[{"start":{"line":31,"column":4},"end":{"line":31,"column":4},"skip":true},{"start":{"line":31,"column":4},"end":{"line":31,"column":4},"skip":true}]},"3":{"line":35,"type":"cond-expr","locations":[{"start":{"line":35,"column":41},"end":{"line":35,"column":54},"skip":true},{"start":{"line":35,"column":57},"end":{"line":35,"column":63},"skip":true}]},"4":{"line":41,"type":"cond-expr","locations":[{"start":{"line":42,"column":2},"end":{"line":42,"column":10}},{"start":{"line":44,"column":2},"end":{"line":48,"column":3},"skip":true}]},"5":{"line":55,"type":"if","locations":[{"start":{"line":55,"column":4},"end":{"line":55,"column":4}},{"start":{"line":55,"column":4},"end":{"line":55,"column":4}}]},"6":{"line":57,"type":"if","locations":[{"start":{"line":57,"column":6},"end":{"line":57,"column":6}},{"start":{"line":57,"column":6},"end":{"line":57,"column":6}}]},"7":{"line":63,"type":"cond-expr","locations":[{"start":{"line":64,"column":2},"end":{"line":64,"column":7}},{"start":{"line":66,"column":2},"end":{"line":73,"column":3},"skip":true}]},"8":{"line":77,"type":"switch","locations":[{"start":{"line":78,"column":4},"end":{"line":78,"column":64}},{"start":{"line":79,"column":4},"end":{"line":84,"column":46}},{"start":{"line":85,"column":4},"end":{"line":98,"column":15}}]},"9":{"line":82,"type":"cond-expr","locations":[{"start":{"line":82,"column":64},"end":{"line":82,"column":69}},{"start":{"line":82,"column":72},"end":{"line":82,"column":75}}]},"10":{"line":82,"type":"binary-expr","locations":[{"start":{"line":82,"column":19},"end":{"line":82,"column":36}},{"start":{"line":82,"column":40},"end":{"line":82,"column":60}}]},"11":{"line":96,"type":"if","locations":[{"start":{"line":96,"column":6},"end":{"line":96,"column":6}},{"start":{"line":96,"column":6},"end":{"line":96,"column":6}}]},"12":{"line":96,"type":"binary-expr","locations":[{"start":{"line":96,"column":10},"end":{"line":96,"column":26}},{"start":{"line":96,"column":31},"end":{"line":96,"column":46}},{"start":{"line":96,"column":50},"end":{"line":96,"column":82}}]}}}} -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var $ = (function () { 2 | 'use strict'; 3 | 4 | function _typeof(obj) { 5 | if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { 6 | _typeof = function (obj) { 7 | return typeof obj; 8 | }; 9 | } else { 10 | _typeof = function (obj) { 11 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 12 | }; 13 | } 14 | 15 | return _typeof(obj); 16 | } 17 | 18 | function _classCallCheck(instance, Constructor) { 19 | if (!(instance instanceof Constructor)) { 20 | throw new TypeError("Cannot call a class as a function"); 21 | } 22 | } 23 | 24 | function _inherits(subClass, superClass) { 25 | if (typeof superClass !== "function" && superClass !== null) { 26 | throw new TypeError("Super expression must either be null or a function"); 27 | } 28 | 29 | subClass.prototype = Object.create(superClass && superClass.prototype, { 30 | constructor: { 31 | value: subClass, 32 | writable: true, 33 | configurable: true 34 | } 35 | }); 36 | if (superClass) _setPrototypeOf(subClass, superClass); 37 | } 38 | 39 | function _getPrototypeOf(o) { 40 | _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { 41 | return o.__proto__ || Object.getPrototypeOf(o); 42 | }; 43 | return _getPrototypeOf(o); 44 | } 45 | 46 | function _setPrototypeOf(o, p) { 47 | _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { 48 | o.__proto__ = p; 49 | return o; 50 | }; 51 | 52 | return _setPrototypeOf(o, p); 53 | } 54 | 55 | function isNativeReflectConstruct() { 56 | if (typeof Reflect === "undefined" || !Reflect.construct) return false; 57 | if (Reflect.construct.sham) return false; 58 | if (typeof Proxy === "function") return true; 59 | 60 | try { 61 | Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); 62 | return true; 63 | } catch (e) { 64 | return false; 65 | } 66 | } 67 | 68 | function _construct(Parent, args, Class) { 69 | if (isNativeReflectConstruct()) { 70 | _construct = Reflect.construct; 71 | } else { 72 | _construct = function _construct(Parent, args, Class) { 73 | var a = [null]; 74 | a.push.apply(a, args); 75 | var Constructor = Function.bind.apply(Parent, a); 76 | var instance = new Constructor(); 77 | if (Class) _setPrototypeOf(instance, Class.prototype); 78 | return instance; 79 | }; 80 | } 81 | 82 | return _construct.apply(null, arguments); 83 | } 84 | 85 | function _isNativeFunction(fn) { 86 | return Function.toString.call(fn).indexOf("[native code]") !== -1; 87 | } 88 | 89 | function _wrapNativeSuper(Class) { 90 | var _cache = typeof Map === "function" ? new Map() : undefined; 91 | 92 | _wrapNativeSuper = function _wrapNativeSuper(Class) { 93 | if (Class === null || !_isNativeFunction(Class)) return Class; 94 | 95 | if (typeof Class !== "function") { 96 | throw new TypeError("Super expression must either be null or a function"); 97 | } 98 | 99 | if (typeof _cache !== "undefined") { 100 | if (_cache.has(Class)) return _cache.get(Class); 101 | 102 | _cache.set(Class, Wrapper); 103 | } 104 | 105 | function Wrapper() { 106 | return _construct(Class, arguments, _getPrototypeOf(this).constructor); 107 | } 108 | 109 | Wrapper.prototype = Object.create(Class.prototype, { 110 | constructor: { 111 | value: Wrapper, 112 | enumerable: false, 113 | writable: true, 114 | configurable: true 115 | } 116 | }); 117 | return _setPrototypeOf(Wrapper, Class); 118 | }; 119 | 120 | return _wrapNativeSuper(Class); 121 | } 122 | 123 | function _assertThisInitialized(self) { 124 | if (self === void 0) { 125 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 126 | } 127 | 128 | return self; 129 | } 130 | 131 | function _possibleConstructorReturn(self, call) { 132 | if (call && (typeof call === "object" || typeof call === "function")) { 133 | return call; 134 | } 135 | 136 | return _assertThisInitialized(self); 137 | } 138 | 139 | /** 140 | * ISC License 141 | * 142 | * Copyright (c) 2018, Andrea Giammarchi, @WebReflection 143 | * 144 | * Permission to use, copy, modify, and/or distribute this software for any 145 | * purpose with or without fee is hereby granted, provided that the above 146 | * copyright notice and this permission notice appear in all copies. 147 | * 148 | * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH 149 | * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY 150 | * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, 151 | * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM 152 | * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE 153 | * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR 154 | * PERFORMANCE OF THIS SOFTWARE. 155 | */ 156 | var QueryResult = 157 | /*#__PURE__*/ 158 | function (_Array) { 159 | _inherits(QueryResult, _Array); 160 | 161 | function QueryResult() { 162 | _classCallCheck(this, QueryResult); 163 | 164 | return _possibleConstructorReturn(this, _getPrototypeOf(QueryResult).apply(this, arguments)); 165 | } 166 | 167 | return QueryResult; 168 | }(_wrapNativeSuper(Array)); 169 | 170 | var create = Object.create, 171 | defineProperty = Object.defineProperty; 172 | var AP = Array.prototype; 173 | var DOM_CONTENT_LOADED = 'DOMContentLoaded'; 174 | var LOAD = 'load'; 175 | var NO_TRANSPILER_ISSUES = new QueryResult() instanceof QueryResult; 176 | var QRP = QueryResult.prototype; // fixes methods returning non QueryResult 177 | 178 | /* istanbul ignore if */ 179 | 180 | if (!NO_TRANSPILER_ISSUES) Object.getOwnPropertyNames(AP).forEach(function (name) { 181 | var desc = Object.getOwnPropertyDescriptor(AP, name); 182 | 183 | if (typeof desc.value === 'function') { 184 | var fn = desc.value; 185 | 186 | desc.value = function () { 187 | var result = fn.apply(this, arguments); 188 | return result instanceof Array ? patch(result) : result; 189 | }; 190 | } 191 | 192 | defineProperty(QRP, name, desc); 193 | }); // fixes badly transpiled classes 194 | 195 | var patch = NO_TRANSPILER_ISSUES ? function (qr) { 196 | return qr; 197 | } : 198 | /* istanbul ignore next */ 199 | function (qr) { 200 | var nqr = create(QRP); 201 | push.apply(nqr, slice(qr)); 202 | return nqr; 203 | }; 204 | var push = AP.push; 205 | 206 | var search = function search(list, el) { 207 | var nodes = []; 208 | var length = list.length; 209 | 210 | for (var i = 0; i < length; i++) { 211 | var css = list[i].trim(); 212 | 213 | if (css.slice(-6) === ':first') { 214 | var node = el.querySelector(css.slice(0, -6)); 215 | if (node) push.call(nodes, node); 216 | } else push.apply(nodes, slice(el.querySelectorAll(css))); 217 | } 218 | 219 | return _construct(QueryResult, nodes); 220 | }; 221 | 222 | var slice = NO_TRANSPILER_ISSUES ? patch : 223 | /* istanbul ignore next */ 224 | function (all) { 225 | // do not use slice.call(...) due old IE gotcha 226 | var nodes = []; 227 | var length = all.length; 228 | 229 | for (var i = 0; i < length; i++) { 230 | nodes[i] = all[i]; 231 | } 232 | 233 | return nodes; 234 | }; // use function to avoid usage of Symbol.hasInstance 235 | // (broken in older browsers anyway) 236 | 237 | var $ = function $(CSS) { 238 | var parent = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : document; 239 | 240 | switch (_typeof(CSS)) { 241 | case 'string': 242 | return patch(search(CSS.split(','), parent)); 243 | 244 | case 'object': 245 | // needed to avoid iterator dance (breaks in older IEs) 246 | var nodes = []; 247 | var all = 'nodeType' in CSS || 'postMessage' in CSS ? [CSS] : CSS; 248 | push.apply(nodes, slice(all)); 249 | return patch(_construct(QueryResult, nodes)); 250 | 251 | case 'function': 252 | var $parent = $(parent); 253 | var $window = $(parent.defaultView); 254 | var handler = { 255 | handleEvent: function handleEvent(event) { 256 | $parent.off(DOM_CONTENT_LOADED, handler); 257 | $window.off(LOAD, handler); 258 | CSS(event); 259 | } 260 | }; 261 | $parent.on(DOM_CONTENT_LOADED, handler); 262 | $window.on(LOAD, handler); 263 | var rs = parent.readyState; 264 | if (rs == 'complete' || rs != 'loading' && !parent.documentElement.doScroll) setTimeout(function () { 265 | return $parent.dispatch(DOM_CONTENT_LOADED); 266 | }); 267 | return $; 268 | } 269 | }; 270 | 271 | $.prototype = QRP; 272 | 273 | $.extend = function (key, value) { 274 | return defineProperty(QRP, key, { 275 | configurable: true, 276 | value: value 277 | }), $; 278 | }; // dropped usage of for-of to avoid broken iteration dance in older IEs 279 | 280 | 281 | $.extend('dispatch', function dispatch(type) { 282 | var init = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; 283 | var event = new CustomEvent(type, init); 284 | var length = this.length; 285 | 286 | for (var i = 0; i < length; i++) { 287 | this[i].dispatchEvent(event); 288 | } 289 | 290 | return this; 291 | }).extend('off', function off(type, handler) { 292 | var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 293 | var length = this.length; 294 | 295 | for (var i = 0; i < length; i++) { 296 | this[i].removeEventListener(type, handler, options); 297 | } 298 | 299 | return this; 300 | }).extend('on', function on(type, handler) { 301 | var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false; 302 | var length = this.length; 303 | 304 | for (var i = 0; i < length; i++) { 305 | this[i].addEventListener(type, handler, options); 306 | } 307 | 308 | return this; 309 | }); 310 | 311 | return $; 312 | 313 | }()); 314 | -------------------------------------------------------------------------------- /coverage/lcov-report/cjs/index.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Code coverage report for cjs/index.js 5 | 6 | 7 | 8 | 9 | 14 | 15 | 16 |
17 |
18 |

19 | all files / cjs/ index.js 20 |

21 |
22 |
23 | 100% 24 | Statements 25 | 76/76 26 |
27 |
28 | 100% 29 | Branches 30 | 26/26 31 |
32 |
33 | 100% 34 | Functions 35 | 6/6 36 |
37 |
38 | 100% 39 | Lines 40 | 74/74 41 |
42 |
43 | 16 statements, 1 function, 7 branches 44 | Ignored      45 |
46 |
47 |
48 |
49 |

 50 | 
426 | 
1 51 | 2 52 | 3 53 | 4 54 | 5 55 | 6 56 | 7 57 | 8 58 | 9 59 | 10 60 | 11 61 | 12 62 | 13 63 | 14 64 | 15 65 | 16 66 | 17 67 | 18 68 | 19 69 | 20 70 | 21 71 | 22 72 | 23 73 | 24 74 | 25 75 | 26 76 | 27 77 | 28 78 | 29 79 | 30 80 | 31 81 | 32 82 | 33 83 | 34 84 | 35 85 | 36 86 | 37 87 | 38 88 | 39 89 | 40 90 | 41 91 | 42 92 | 43 93 | 44 94 | 45 95 | 46 96 | 47 97 | 48 98 | 49 99 | 50 100 | 51 101 | 52 102 | 53 103 | 54 104 | 55 105 | 56 106 | 57 107 | 58 108 | 59 109 | 60 110 | 61 111 | 62 112 | 63 113 | 64 114 | 65 115 | 66 116 | 67 117 | 68 118 | 69 119 | 70 120 | 71 121 | 72 122 | 73 123 | 74 124 | 75 125 | 76 126 | 77 127 | 78 128 | 79 129 | 80 130 | 81 131 | 82 132 | 83 133 | 84 134 | 85 135 | 86 136 | 87 137 | 88 138 | 89 139 | 90 140 | 91 141 | 92 142 | 93 143 | 94 144 | 95 145 | 96 146 | 97 147 | 98 148 | 99 149 | 100 150 | 101 151 | 102 152 | 103 153 | 104 154 | 105 155 | 106 156 | 107 157 | 108 158 | 109 159 | 110 160 | 111 161 | 112 162 | 113 163 | 114 164 | 115 165 | 116 166 | 117 167 | 118 168 | 119 169 | 120 170 | 121 171 | 122 172 | 123 173 | 124 174 | 125 175 | 126  176 |   177 |   178 |   179 |   180 |   181 |   182 |   183 |   184 |   185 |   186 |   187 |   188 |   189 |   190 |   191 |   192 |   193 |   194 | 195 | 196 | 197 | 198 | 199 | 200 |   201 |   202 | 203 | 204 | 205 | 206 | 207 | 208 | 209 | 210 |   211 |   212 | 213 |   214 |   215 | 216 | 15× 217 |   218 |   219 | 220 | 221 | 222 |   223 | 224 | 225 | 226 | 227 | 228 | 229 | 230 | 231 | 232 |   233 | 234 |   235 | 236 |   237 | 238 |   239 |   240 |   241 |   242 | 243 | 244 | 245 | 246 | 247 |   248 |   249 |   250 | 251 | 10× 252 | 253 |   254 |   255 | 256 | 257 | 258 | 259 |   260 | 261 | 262 | 263 | 264 | 265 | 266 |   267 | 268 | 269 | 270 | 271 | 272 | 273 |   274 |   275 | 276 | 277 | 278 |   279 | 280 | 281 | 282 | 283 | 284 | 285 |   286 |   287 | 288 | 289 | 290 | 291 |   292 |   293 | 294 | 295 | 296 | 297 |   298 |   299 | 300 |  
'use strict';
301 | /**
302 |  * ISC License
303 |  *
304 |  * Copyright (c) 2018, Andrea Giammarchi, @WebReflection
305 |  *
306 |  * Permission to use, copy, modify, and/or distribute this software for any
307 |  * purpose with or without fee is hereby granted, provided that the above
308 |  * copyright notice and this permission notice appear in all copies.
309 |  *
310 |  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
311 |  * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
312 |  * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
313 |  * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
314 |  * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
315 |  * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
316 |  * PERFORMANCE OF THIS SOFTWARE.
317 |  */
318 | class QueryResult extends Array {}
319 | const {create, defineProperty} = Object;
320 | const AP = Array.prototype;
321 | const DOM_CONTENT_LOADED = 'DOMContentLoaded';
322 | const LOAD = 'load';
323 | const NO_TRANSPILER_ISSUES = (new QueryResult) instanceof QueryResult;
324 | const QRP = QueryResult.prototype;
325 | // fixes methods returning non QueryResult
326 | /* istanbul ignore if */
327 | Iif (!NO_TRANSPILER_ISSUES)
328 |   Object.getOwnPropertyNames(AP).forEach(name => {
329 |     const desc = Object.getOwnPropertyDescriptor(AP, name);
330 |     if (typeof desc.value === 'function') {
331 |       const fn = desc.value;
332 |       desc.value = function () {
333 |         const result = fn.apply(this, arguments);
334 |         return result instanceof Array ? patch(result) : result;
335 |       };
336 |     }
337 |     defineProperty(QRP, name, desc);
338 |   });
339 | // fixes badly transpiled classes
340 | const patch = NO_TRANSPILER_ISSUES ?
341 |   qr => qr :
342 |   /* istanbul ignore next */
343 |   qr => {
344 |     const nqr = create(QRP);
345 |     push.apply(nqr, slice(qr));
346 |     return nqr;
347 |   };
348 | const push = AP.push;
349 | const search = (list, el) => {
350 |   const nodes = [];
351 |   const length = list.length;
352 |   for (let i = 0; i < length; i++) {
353 |     const css = list[i].trim();
354 |     if (css.slice(-6) === ':first') {
355 |       const node = el.querySelector(css.slice(0, -6));
356 |       if (node) push.call(nodes, node);
357 |     } else
358 |       push.apply(nodes, slice(el.querySelectorAll(css)));
359 |   }
360 |   return new QueryResult(...nodes);
361 | };
362 | const slice = NO_TRANSPILER_ISSUES ?
363 |   patch :
364 |   /* istanbul ignore next */
365 |   all => {
366 |     // do not use slice.call(...) due old IE gotcha
367 |     const nodes = [];
368 |     const length = all.length;
369 |     for (let i = 0; i < length; i++)
370 |       nodes[i] = all[i];
371 |     return nodes;
372 |   }
373 | // use function to avoid usage of Symbol.hasInstance
374 | // (broken in older browsers anyway)
375 | const $ = function $(CSS, parent = document) {
376 |   switch (typeof CSS) {
377 |     case 'string': return patch(search(CSS.split(','), parent));
378 |     case 'object':
379 |       // needed to avoid iterator dance (breaks in older IEs)
380 |       const nodes = [];
381 |       const all = ('nodeType' in CSS || 'postMessage' in CSS) ? [CSS] : CSS;
382 |       push.apply(nodes, slice(all));
383 |       return patch(new QueryResult(...nodes));
384 |     case 'function':
385 |       const $parent = $(parent);
386 |       const $window = $(parent.defaultView);
387 |       const handler = {handleEvent(event) {
388 |         $parent.off(DOM_CONTENT_LOADED, handler);
389 |         $window.off(LOAD, handler);
390 |         CSS(event);
391 |       }};
392 |       $parent.on(DOM_CONTENT_LOADED, handler);
393 |       $window.on(LOAD, handler);
394 |       const rs = parent.readyState;
395 |       if (rs == 'complete' || (rs != 'loading' && !parent.documentElement.doScroll))
396 |         setTimeout(() => $parent.dispatch(DOM_CONTENT_LOADED));
397 |       return $;
398 |   }
399 | };
400 | $.prototype = QRP;
401 | $.extend = (key, value) =>
402 |             (defineProperty(QRP, key, {configurable: true, value}), $);
403 | // dropped usage of for-of to avoid broken iteration dance in older IEs
404 | $.extend('dispatch', function dispatch(type, init = {}) {
405 |   const event = new CustomEvent(type, init);
406 |   const length = this.length;
407 |   for (let i = 0; i < length; i++)
408 |     this[i].dispatchEvent(event);
409 |   return this;
410 | })
411 | .extend('off', function off(type, handler, options = false) {
412 |   const length = this.length;
413 |   for (let i = 0; i < length; i++)
414 |     this[i].removeEventListener(type, handler, options);
415 |   return this;
416 | })
417 | .extend('on', function on(type, handler, options = false) {
418 |   const length = this.length;
419 |   for (let i = 0; i < length; i++)
420 |     this[i].addEventListener(type, handler, options);
421 |   return this;
422 | });
423 |  
424 | Object.defineProperty(exports, '__esModule', {value: true}).default = $;
425 |  
427 |
428 |
429 | 433 | 434 | 435 | 442 | 443 | 444 | 445 | -------------------------------------------------------------------------------- /coverage/lcov-report/prettify.js: -------------------------------------------------------------------------------- 1 | window.PR_SHOULD_USE_CONTINUATION=true;(function(){var h=["break,continue,do,else,for,if,return,while"];var u=[h,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"];var p=[u,"catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"];var l=[p,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"];var x=[p,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"];var R=[x,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"];var r="all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes";var w=[p,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"];var s="caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END";var I=[h,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"];var f=[h,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"];var H=[h,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"];var A=[l,R,w,s+I,f,H];var e=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/;var C="str";var z="kwd";var j="com";var O="typ";var G="lit";var L="pun";var F="pln";var m="tag";var E="dec";var J="src";var P="atn";var n="atv";var N="nocode";var M="(?:^^\\.?|[+-]|\\!|\\!=|\\!==|\\#|\\%|\\%=|&|&&|&&=|&=|\\(|\\*|\\*=|\\+=|\\,|\\-=|\\->|\\/|\\/=|:|::|\\;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|\\?|\\@|\\[|\\^|\\^=|\\^\\^|\\^\\^=|\\{|\\||\\|=|\\|\\||\\|\\|=|\\~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\\s*";function k(Z){var ad=0;var S=false;var ac=false;for(var V=0,U=Z.length;V122)){if(!(al<65||ag>90)){af.push([Math.max(65,ag)|32,Math.min(al,90)|32])}if(!(al<97||ag>122)){af.push([Math.max(97,ag)&~32,Math.min(al,122)&~32])}}}}af.sort(function(av,au){return(av[0]-au[0])||(au[1]-av[1])});var ai=[];var ap=[NaN,NaN];for(var ar=0;arat[0]){if(at[1]+1>at[0]){an.push("-")}an.push(T(at[1]))}}an.push("]");return an.join("")}function W(al){var aj=al.source.match(new RegExp("(?:\\[(?:[^\\x5C\\x5D]|\\\\[\\s\\S])*\\]|\\\\u[A-Fa-f0-9]{4}|\\\\x[A-Fa-f0-9]{2}|\\\\[0-9]+|\\\\[^ux0-9]|\\(\\?[:!=]|[\\(\\)\\^]|[^\\x5B\\x5C\\(\\)\\^]+)","g"));var ah=aj.length;var an=[];for(var ak=0,am=0;ak=2&&ai==="["){aj[ak]=X(ag)}else{if(ai!=="\\"){aj[ak]=ag.replace(/[a-zA-Z]/g,function(ao){var ap=ao.charCodeAt(0);return"["+String.fromCharCode(ap&~32,ap|32)+"]"})}}}}return aj.join("")}var aa=[];for(var V=0,U=Z.length;V=0;){S[ac.charAt(ae)]=Y}}var af=Y[1];var aa=""+af;if(!ag.hasOwnProperty(aa)){ah.push(af);ag[aa]=null}}ah.push(/[\0-\uffff]/);V=k(ah)})();var X=T.length;var W=function(ah){var Z=ah.sourceCode,Y=ah.basePos;var ad=[Y,F];var af=0;var an=Z.match(V)||[];var aj={};for(var ae=0,aq=an.length;ae=5&&"lang-"===ap.substring(0,5);if(am&&!(ai&&typeof ai[1]==="string")){am=false;ap=J}if(!am){aj[ag]=ap}}var ab=af;af+=ag.length;if(!am){ad.push(Y+ab,ap)}else{var al=ai[1];var ak=ag.indexOf(al);var ac=ak+al.length;if(ai[2]){ac=ag.length-ai[2].length;ak=ac-al.length}var ar=ap.substring(5);B(Y+ab,ag.substring(0,ak),W,ad);B(Y+ab+ak,al,q(ar,al),ad);B(Y+ab+ac,ag.substring(ac),W,ad)}}ah.decorations=ad};return W}function i(T){var W=[],S=[];if(T.tripleQuotedStrings){W.push([C,/^(?:\'\'\'(?:[^\'\\]|\\[\s\S]|\'{1,2}(?=[^\']))*(?:\'\'\'|$)|\"\"\"(?:[^\"\\]|\\[\s\S]|\"{1,2}(?=[^\"]))*(?:\"\"\"|$)|\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$))/,null,"'\""])}else{if(T.multiLineStrings){W.push([C,/^(?:\'(?:[^\\\']|\\[\s\S])*(?:\'|$)|\"(?:[^\\\"]|\\[\s\S])*(?:\"|$)|\`(?:[^\\\`]|\\[\s\S])*(?:\`|$))/,null,"'\"`"])}else{W.push([C,/^(?:\'(?:[^\\\'\r\n]|\\.)*(?:\'|$)|\"(?:[^\\\"\r\n]|\\.)*(?:\"|$))/,null,"\"'"])}}if(T.verbatimStrings){S.push([C,/^@\"(?:[^\"]|\"\")*(?:\"|$)/,null])}var Y=T.hashComments;if(Y){if(T.cStyleComments){if(Y>1){W.push([j,/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,null,"#"])}else{W.push([j,/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\r\n]*)/,null,"#"])}S.push([C,/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,null])}else{W.push([j,/^#[^\r\n]*/,null,"#"])}}if(T.cStyleComments){S.push([j,/^\/\/[^\r\n]*/,null]);S.push([j,/^\/\*[\s\S]*?(?:\*\/|$)/,null])}if(T.regexLiterals){var X=("/(?=[^/*])(?:[^/\\x5B\\x5C]|\\x5C[\\s\\S]|\\x5B(?:[^\\x5C\\x5D]|\\x5C[\\s\\S])*(?:\\x5D|$))+/");S.push(["lang-regex",new RegExp("^"+M+"("+X+")")])}var V=T.types;if(V){S.push([O,V])}var U=(""+T.keywords).replace(/^ | $/g,"");if(U.length){S.push([z,new RegExp("^(?:"+U.replace(/[\s,]+/g,"|")+")\\b"),null])}W.push([F,/^\s+/,null," \r\n\t\xA0"]);S.push([G,/^@[a-z_$][a-z_$@0-9]*/i,null],[O,/^(?:[@_]?[A-Z]+[a-z][A-Za-z_$@0-9]*|\w+_t\b)/,null],[F,/^[a-z_$][a-z_$@0-9]*/i,null],[G,new RegExp("^(?:0x[a-f0-9]+|(?:\\d(?:_\\d+)*\\d*(?:\\.\\d*)?|\\.\\d\\+)(?:e[+\\-]?\\d+)?)[a-z]*","i"),null,"0123456789"],[F,/^\\[\s\S]?/,null],[L,/^.[^\s\w\.$@\'\"\`\/\#\\]*/,null]);return g(W,S)}var K=i({keywords:A,hashComments:true,cStyleComments:true,multiLineStrings:true,regexLiterals:true});function Q(V,ag){var U=/(?:^|\s)nocode(?:\s|$)/;var ab=/\r\n?|\n/;var ac=V.ownerDocument;var S;if(V.currentStyle){S=V.currentStyle.whiteSpace}else{if(window.getComputedStyle){S=ac.defaultView.getComputedStyle(V,null).getPropertyValue("white-space")}}var Z=S&&"pre"===S.substring(0,3);var af=ac.createElement("LI");while(V.firstChild){af.appendChild(V.firstChild)}var W=[af];function ae(al){switch(al.nodeType){case 1:if(U.test(al.className)){break}if("BR"===al.nodeName){ad(al);if(al.parentNode){al.parentNode.removeChild(al)}}else{for(var an=al.firstChild;an;an=an.nextSibling){ae(an)}}break;case 3:case 4:if(Z){var am=al.nodeValue;var aj=am.match(ab);if(aj){var ai=am.substring(0,aj.index);al.nodeValue=ai;var ah=am.substring(aj.index+aj[0].length);if(ah){var ak=al.parentNode;ak.insertBefore(ac.createTextNode(ah),al.nextSibling)}ad(al);if(!ai){al.parentNode.removeChild(al)}}}break}}function ad(ak){while(!ak.nextSibling){ak=ak.parentNode;if(!ak){return}}function ai(al,ar){var aq=ar?al.cloneNode(false):al;var ao=al.parentNode;if(ao){var ap=ai(ao,1);var an=al.nextSibling;ap.appendChild(aq);for(var am=an;am;am=an){an=am.nextSibling;ap.appendChild(am)}}return aq}var ah=ai(ak.nextSibling,0);for(var aj;(aj=ah.parentNode)&&aj.nodeType===1;){ah=aj}W.push(ah)}for(var Y=0;Y=S){ah+=2}if(V>=ap){Z+=2}}}var t={};function c(U,V){for(var S=V.length;--S>=0;){var T=V[S];if(!t.hasOwnProperty(T)){t[T]=U}else{if(window.console){console.warn("cannot override language handler %s",T)}}}}function q(T,S){if(!(T&&t.hasOwnProperty(T))){T=/^\s*]*(?:>|$)/],[j,/^<\!--[\s\S]*?(?:-\->|$)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],[L,/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]),["default-markup","htm","html","mxml","xhtml","xml","xsl"]);c(g([[F,/^[\s]+/,null," \t\r\n"],[n,/^(?:\"[^\"]*\"?|\'[^\']*\'?)/,null,"\"'"]],[[m,/^^<\/?[a-z](?:[\w.:-]*\w)?|\/?>$/i],[P,/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^>\'\"\s]*(?:[^>\'\"\s\/]|\/(?=\s)))/],[L,/^[=<>\/]+/],["lang-js",/^on\w+\s*=\s*\"([^\"]+)\"/i],["lang-js",/^on\w+\s*=\s*\'([^\']+)\'/i],["lang-js",/^on\w+\s*=\s*([^\"\'>\s]+)/i],["lang-css",/^style\s*=\s*\"([^\"]+)\"/i],["lang-css",/^style\s*=\s*\'([^\']+)\'/i],["lang-css",/^style\s*=\s*([^\"\'>\s]+)/i]]),["in.tag"]);c(g([],[[n,/^[\s\S]+/]]),["uq.val"]);c(i({keywords:l,hashComments:true,cStyleComments:true,types:e}),["c","cc","cpp","cxx","cyc","m"]);c(i({keywords:"null,true,false"}),["json"]);c(i({keywords:R,hashComments:true,cStyleComments:true,verbatimStrings:true,types:e}),["cs"]);c(i({keywords:x,cStyleComments:true}),["java"]);c(i({keywords:H,hashComments:true,multiLineStrings:true}),["bsh","csh","sh"]);c(i({keywords:I,hashComments:true,multiLineStrings:true,tripleQuotedStrings:true}),["cv","py"]);c(i({keywords:s,hashComments:true,multiLineStrings:true,regexLiterals:true}),["perl","pl","pm"]);c(i({keywords:f,hashComments:true,multiLineStrings:true,regexLiterals:true}),["rb"]);c(i({keywords:w,cStyleComments:true,regexLiterals:true}),["js"]);c(i({keywords:r,hashComments:3,cStyleComments:true,multilineStrings:true,tripleQuotedStrings:true,regexLiterals:true}),["coffee"]);c(g([],[[C,/^[\s\S]+/]]),["regex"]);function d(V){var U=V.langExtension;try{var S=a(V.sourceNode);var T=S.sourceCode;V.sourceCode=T;V.spans=S.spans;V.basePos=0;q(U,T)(V);D(V)}catch(W){if("console" in window){console.log(W&&W.stack?W.stack:W)}}}function y(W,V,U){var S=document.createElement("PRE");S.innerHTML=W;if(U){Q(S,U)}var T={langExtension:V,numberLines:U,sourceNode:S};d(T);return S.innerHTML}function b(ad){function Y(af){return document.getElementsByTagName(af)}var ac=[Y("pre"),Y("code"),Y("xmp")];var T=[];for(var aa=0;aa=0){var ah=ai.match(ab);var am;if(!ah&&(am=o(aj))&&"CODE"===am.tagName){ah=am.className.match(ab)}if(ah){ah=ah[1]}var al=false;for(var ak=aj.parentNode;ak;ak=ak.parentNode){if((ak.tagName==="pre"||ak.tagName==="code"||ak.tagName==="xmp")&&ak.className&&ak.className.indexOf("prettyprint")>=0){al=true;break}}if(!al){var af=aj.className.match(/\blinenums\b(?::(\d+))?/);af=af?af[1]&&af[1].length?+af[1]:true:false;if(af){Q(aj,af)}S={langExtension:ah,sourceNode:aj,numberLines:af};d(S)}}}if(X]*(?:>|$)/],[PR.PR_COMMENT,/^<\!--[\s\S]*?(?:-\->|$)/],[PR.PR_PUNCTUATION,/^(?:<[%?]|[%?]>)/],["lang-",/^<\?([\s\S]+?)(?:\?>|$)/],["lang-",/^<%([\s\S]+?)(?:%>|$)/],["lang-",/^]*>([\s\S]+?)<\/xmp\b[^>]*>/i],["lang-handlebars",/^]*type\s*=\s*['"]?text\/x-handlebars-template['"]?\b[^>]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-js",/^]*>([\s\S]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\s\S]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i],[PR.PR_DECLARATION,/^{{[#^>/]?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{&?\s*[\w.][^}]*}}/],[PR.PR_DECLARATION,/^{{{>?\s*[\w.][^}]*}}}/],[PR.PR_COMMENT,/^{{![^}]*}}/]]),["handlebars","hbs"]);PR.registerLangHandler(PR.createSimpleLexer([[PR.PR_PLAIN,/^[ \t\r\n\f]+/,null," \t\r\n\f"]],[[PR.PR_STRING,/^\"(?:[^\n\r\f\\\"]|\\(?:\r\n?|\n|\f)|\\[\s\S])*\"/,null],[PR.PR_STRING,/^\'(?:[^\n\r\f\\\']|\\(?:\r\n?|\n|\f)|\\[\s\S])*\'/,null],["lang-css-str",/^url\(([^\)\"\']*)\)/i],[PR.PR_KEYWORD,/^(?:url|rgb|\!important|@import|@page|@media|@charset|inherit)(?=[^\-\w]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|(?:\\[0-9a-f]+ ?))(?:[_a-z0-9\-]|\\(?:\\[0-9a-f]+ ?))*)\s*:/i],[PR.PR_COMMENT,/^\/\*[^*]*\*+(?:[^\/*][^*]*\*+)*\//],[PR.PR_COMMENT,/^(?:)/],[PR.PR_LITERAL,/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],[PR.PR_LITERAL,/^#(?:[0-9a-f]{3}){1,2}/i],[PR.PR_PLAIN,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i],[PR.PR_PUNCTUATION,/^[^\s\w\'\"]+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_KEYWORD,/^-?(?:[_a-z]|(?:\\[\da-f]+ ?))(?:[_a-z\d\-]|\\(?:\\[\da-f]+ ?))*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[[PR.PR_STRING,/^[^\)\"\']+/]]),["css-str"]); 2 | --------------------------------------------------------------------------------