├── .jshintignore ├── .gitignore ├── resources └── sektor.png ├── .editorconfig ├── .jshintrc ├── bower.json ├── CHANGELOG.md ├── LICENSE ├── package.json ├── dist ├── sektor.min.js └── sektor.js ├── src └── sektor.js ├── README.md └── gulpfile.js /.jshintignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | dist 3 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | bower_components 3 | -------------------------------------------------------------------------------- /resources/sektor.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bevacqua/sektor/HEAD/resources/sektor.png -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | # editorconfig.org 2 | root = true 3 | 4 | [*] 5 | indent_style = space 6 | indent_size = 2 7 | end_of_line = lf 8 | charset = utf-8 9 | trim_trailing_whitespace = true 10 | insert_final_newline = true 11 | 12 | [*.md] 13 | trim_trailing_whitespace = false 14 | -------------------------------------------------------------------------------- /.jshintrc: -------------------------------------------------------------------------------- 1 | { 2 | "curly": true, 3 | "eqeqeq": true, 4 | "newcap": true, 5 | "noarg": true, 6 | "noempty": true, 7 | "nonew": true, 8 | "sub": true, 9 | "undef": true, 10 | "unused": true, 11 | "trailing": true, 12 | "boss": true, 13 | "eqnull": true, 14 | "strict": true, 15 | "immed": true, 16 | "expr": true, 17 | "latedef": "nofunc", 18 | "quotmark": "single", 19 | "indent": 2, 20 | "node": true 21 | } 22 | -------------------------------------------------------------------------------- /bower.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sektor", 3 | "description": "A slim alternative to jQuery's Sizzle", 4 | "version": "1.1.4", 5 | "homepage": "https://github.com/bevacqua/sektor", 6 | "author": { 7 | "name": "Nicolas Bevacqua", 8 | "email": "ng@bevacqua.io", 9 | "url": "http://bevacqua.io" 10 | }, 11 | "license": "MIT", 12 | "repository": { 13 | "type": "git", 14 | "url": "git://github.com/bevacqua/sektor.git" 15 | }, 16 | "main": "dist/sektor.js", 17 | "ignore": [ 18 | ".*", 19 | "package.json", 20 | "node_modules", 21 | "src", 22 | "index.html", 23 | "gulpfile.js" 24 | ], 25 | "dependencies": {} 26 | } 27 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # 1.1.4 Mortal Kombat 2 2 | 3 | - Sektor now ignores API limitations on the server-side, instead of throwing 4 | 5 | # 1.1.1 Short Circuit 6 | 7 | - Less bytes 8 | 9 | # 1.1.0 Query Major 10 | 11 | - Addressed an issue where `.querySelectorAll` would return elements incorrectly when passing a context root 12 | - Fixed a bug where contextual queries without a prefix, such as `sektor('> foo', div)` would fail 13 | - When providing an invalid selector, queries silently fail instead of throwing DOM errors 14 | 15 | # 1.0.1 Minority Rapport 16 | 17 | - Fixed a bug in `.matchesSelector` code path 18 | 19 | # 1.0.0 IPO 20 | 21 | - Initial Public Release 22 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright © 2014 Nicolas Bevacqua 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of 9 | the Software, and to permit persons to whom the Software is furnished to do so, 10 | subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS 17 | FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 18 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER 19 | IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN 20 | CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 21 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "sektor", 3 | "description": "A slim alternative to jQuery's Sizzle", 4 | "version": "1.1.5", 5 | "homepage": "https://github.com/bevacqua/sektor", 6 | "author": { 7 | "name": "Nicolas Bevacqua", 8 | "email": "ng@bevacqua.io", 9 | "url": "http://bevacqua.io" 10 | }, 11 | "main": "src/sektor.js", 12 | "license": "MIT", 13 | "repository": { 14 | "type": "git", 15 | "url": "git://github.com/bevacqua/sektor.git" 16 | }, 17 | "devDependencies": { 18 | "browserify": "^4.2.1", 19 | "contra": "^1.6.10", 20 | "gulp": "^3.6.2", 21 | "gulp-bump": "~0.1.0", 22 | "gulp-clean": "~0.2.3", 23 | "gulp-concat": "~2.1.7", 24 | "gulp-git": "~0.2.0", 25 | "gulp-header": "^1.0.2", 26 | "gulp-jshint": "~1.3.4", 27 | "gulp-mocha": "~0.3.0", 28 | "gulp-rename": "~0.2.2", 29 | "gulp-size": "~0.1.1", 30 | "gulp-streamify": "0.0.5", 31 | "gulp-uglify": "~0.1.0", 32 | "gzip-size": "^1.0.0", 33 | "jshint": "~2.4.1", 34 | "jshint-stylish": "~0.1.5", 35 | "jshint-tap": "0.0.1", 36 | "pretty-bytes": "^1.0.1", 37 | "sizzle": "*", 38 | "vinyl-source-stream": "^0.1.1" 39 | }, 40 | "dependencies": {} 41 | } 42 | -------------------------------------------------------------------------------- /dist/sektor.min.js: -------------------------------------------------------------------------------- 1 | // sektor@v1.1.4, MIT licensed. https://github.com/bevacqua/sektor 2 | !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;"undefined"!=typeof window?t=window:"undefined"!=typeof global?t=global:"undefined"!=typeof self&&(t=self),t.sektor=e()}}(function(){return function e(t,n,r){function o(i,f){if(!n[i]){if(!t[i]){var l="function"==typeof require&&require;if(!f&&l)return l(i,!0);if(u)return u(i,!0);throw new Error("Cannot find module '"+i+"'")}var c=n[i]={exports:{}};t[i][0].call(c.exports,function(e){var n=t[i][1][e];return o(n?n:e)},c,c.exports,e,t,n,r)}return n[i].exports}for(var u="function"==typeof require&&require,i=0;i A slim alternative to jQuery's [Sizzle][1] 4 | 5 | Sektor has a smaller footprint than that of [Sizzle][1]. Sektor is [**836B**][3] minified and gzipped, vs the [**7.01kB**][2] in Sizzle. 6 | 7 | This is the selector engine used in [Dominus][4]. 8 | 9 | # Install 10 | 11 | ```shell 12 | npm install sektor --save 13 | ``` 14 | 15 | ```shell 16 | bower install sektor --save 17 | ``` 18 | 19 | # Usage 20 | 21 | The public API exposed by `sektor` mirrors the API in [Sizzle][1]. This means `sektor` is a drop-in replacement for [Sizzle][1]. 22 | 23 | # Drawbacks 24 | 25 | Sektor has a few drawbacks when compared against [Sizzle][1]. The following features are **missing in `sektor`, but available in [Sizzle][1]**. If you want any of these, use [Sizzle][1] instead! 26 | 27 | ##### Missing features 28 | 29 | Sektor lacks support for custom state-based selectors popularized by Sizzle, such as `:visible`, `:first`, and so on. 30 | 31 | While [Sizzle][1] fixes a few cross-browser incompatibilities by providing their own full-blown selection engine, Sektor doesn't fix all of them. You can check the complete list of cross-browser incompatibilities Sizzle fixes [in their source code][6]. 32 | 33 | Sektor _does_ correct the behavior in `.querySelectorAll` [for context-rooted queries][7]. 34 | 35 | ##### Features I'm glad are missing 36 | 37 | I consider these "features" bloat, and thus they aren't implemented in `sektor`. 38 | 39 | * Attribute not equal selector 40 | * Positional selectors (`:first`; `:eq(n)`; `:odd`; etc.) 41 | * Type selectors (`:input`; `:checkbox`; `:button`; etc.) 42 | * `:has(selector)` 43 | * Complex negations `:not(complex selector)` 44 | * Adding custom selectors via Sizzle extensions 45 | * Reliable functionality on XML fragments 46 | * Matching against non-elements 47 | * Reliable sorting of disconnected nodes 48 | 49 | # License 50 | 51 | MIT 52 | 53 | [1]: https://github.com/jquery/sizzle 54 | [2]: https://github.com/jquery/sizzle/blob/master/dist/sizzle.min.js 55 | [3]: https://github.com/bevacqua/sektor/blob/master/dist/sektor.min.js 56 | [4]: https://github.com/bevacqua/dominus 57 | [5]: https://raw.githubusercontent.com/bevacqua/sektor/master/resources/sektor.png 58 | [6]: https://github.com/jquery/sizzle/blob/5bc4454a18b859025cbb8480c70bd3b7ec623ac0/src/sizzle.js#L602-L676 59 | [7]: http://ejohn.org/blog/thoughts-on-queryselectorall/ 60 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | var prettyBytes = require('pretty-bytes'); 4 | var gzipSize = require('gzip-size'); 5 | var fs = require('fs'); 6 | var path = require('path'); 7 | var contra = require('contra'); 8 | var gulp = require('gulp'); 9 | var bump = require('gulp-bump'); 10 | var git = require('gulp-git'); 11 | var clean = require('gulp-clean'); 12 | var rename = require('gulp-rename'); 13 | var header = require('gulp-header'); 14 | var uglify = require('gulp-uglify'); 15 | var browserify = require('browserify'); 16 | var streamify = require('gulp-streamify'); 17 | var source = require('vinyl-source-stream'); 18 | var size = require('gulp-size'); 19 | 20 | var extended = [ 21 | '/**', 22 | ' * <%= pkg.name %> - <%= pkg.description %>', 23 | ' * @version v<%= pkg.version %>', 24 | ' * @link <%= pkg.homepage %>', 25 | ' * @license <%= pkg.license %>', 26 | ' */', 27 | '' 28 | ].join('\n'); 29 | 30 | var succint = '// <%= pkg.name %>@v<%= pkg.version %>, <%= pkg.license %> licensed. <%= pkg.homepage %>\n'; 31 | 32 | function build (done) { 33 | var pkg = require('./package.json'); 34 | 35 | browserify('./src/sektor.js') 36 | .bundle({ debug: true, standalone: 'sektor' }) 37 | .pipe(source('sektor.js')) 38 | .pipe(streamify(header(extended, { pkg : pkg } ))) 39 | .pipe(gulp.dest('./dist')) 40 | .pipe(streamify(rename('sektor.min.js'))) 41 | .pipe(streamify(uglify())) 42 | .pipe(streamify(header(succint, { pkg : pkg } ))) 43 | .pipe(streamify(size())) 44 | .pipe(gulp.dest('./dist')) 45 | .on('end', footprint.bind(null, done)); 46 | } 47 | 48 | function bumpOnly () { 49 | var bumpType = process.env.BUMP || 'patch'; // major.minor.patch 50 | 51 | return gulp.src(['./package.json', './bower.json']) 52 | .pipe(bump({ type: bumpType })) 53 | .pipe(gulp.dest('./')); 54 | } 55 | 56 | function replaceFootprint (needle, relative, done) { 57 | var file = path.resolve(relative); 58 | var data = fs.readFileSync(file); 59 | var size = gzipSize.sync(data); 60 | var sizeHuman = prettyBytes(size).replace(/\s+/g, ''); 61 | var readmeFile = path.resolve('./README.md'); 62 | var readme = fs.readFileSync(readmeFile, { encoding: 'utf8' }); 63 | var output = readme.replace(needle, '$1' + sizeHuman + '$3'); 64 | 65 | fs.writeFile(readmeFile, output, { encoding: 'utf8'}, done); 66 | } 67 | 68 | function footprint (done) { 69 | var sektorNeedle = /(Sektor is \[\*\*)(.*)(\*\*\]\[\d+\]<\/span>)/mig; 70 | var sizzleNeedle = /(the \[\*\*)(.*)(\*\*\]\[\d+\] in Sizzle<\/span>)/mig; 71 | 72 | contra.series([ 73 | contra.curry(replaceFootprint, sektorNeedle, './dist/sektor.min.js'), 74 | contra.curry(replaceFootprint, sizzleNeedle, './node_modules/sizzle/dist/sizzle.min.js') 75 | ], done); 76 | } 77 | 78 | function tag () { 79 | var pkg = require('./package.json'); 80 | var v = 'v' + pkg.version; 81 | var message = 'Release ' + v; 82 | 83 | return gulp.src('./') 84 | .pipe(git.commit(message)) 85 | .pipe(git.tag(v, message)) 86 | .pipe(git.push('origin', 'master', '--tags')) 87 | .pipe(gulp.dest('./')); 88 | } 89 | 90 | function publish (done) { 91 | require('child_process').exec('npm publish', { stdio: 'inherit' }, done); 92 | } 93 | 94 | gulp.task('clean', function () { 95 | gulp.src('./dist', { read: false }) 96 | .pipe(clean()); 97 | }); 98 | 99 | gulp.task('footprint', footprint); 100 | gulp.task('build', ['clean'], build); 101 | gulp.task('bump', bumpOnly); 102 | gulp.task('bump-build', ['bump'], build); 103 | gulp.task('tag', ['bump-build'], tag); 104 | gulp.task('npm', publish); 105 | gulp.task('release', ['tag', 'npm']); 106 | -------------------------------------------------------------------------------- /dist/sektor.js: -------------------------------------------------------------------------------- 1 | /** 2 | * sektor - A slim alternative to jQuery's Sizzle 3 | * @version v1.1.4 4 | * @link https://github.com/bevacqua/sektor 5 | * @license MIT 6 | */ 7 | !function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.sektor=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);throw new Error("Cannot find module '"+o+"'")}var f=n[o]={exports:{}};t[o][0].call(f.exports,function(e){var n=t[o][1][e];return s(n?n:e)},f,f.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o