mirror of
https://github.com/snachodog/just-the-docs.git
synced 2025-09-12 21:03:32 -06:00
Initial commit
This commit is contained in:
1
node_modules/normalize-selector/.npmignore
generated
vendored
Normal file
1
node_modules/normalize-selector/.npmignore
generated
vendored
Normal file
@@ -0,0 +1 @@
|
||||
node_modules
|
34
node_modules/normalize-selector/README.md
generated
vendored
Normal file
34
node_modules/normalize-selector/README.md
generated
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
# Normalize-Selector
|
||||
|
||||
Normalize CSS selectors.
|
||||
|
||||
Examples:
|
||||
|
||||
* `#foo>.bar` -> `#foo > .bar`
|
||||
* ` #foo > .bar ` -> `#foo > .bar`
|
||||
* `foo[ a = 'b' ]` -> `foo[a='b']`
|
||||
|
||||
## Tests
|
||||
|
||||
Run mocha tests on node.js with:
|
||||
|
||||
```
|
||||
npm test
|
||||
```
|
||||
|
||||
or:
|
||||
|
||||
```
|
||||
node ./test/mocha/node-suite.js
|
||||
```
|
||||
|
||||
## rawgithub
|
||||
|
||||
View the browser suite directly on
|
||||
[rawgithub](https://rawgithub.com/getify/normalize-selector/master/test/mocha/browser-suite.html)
|
||||
|
||||
## License
|
||||
|
||||
The code and all the documentation are released under the MIT license.
|
||||
|
||||
http://getify.mit-license.org/
|
163
node_modules/normalize-selector/lib/normalize-selector.js
generated
vendored
Normal file
163
node_modules/normalize-selector/lib/normalize-selector.js
generated
vendored
Normal file
@@ -0,0 +1,163 @@
|
||||
/* normalize-selector v0.1.0 (c) 2014 Kyle Simpson */
|
||||
|
||||
(function UMD(name,context,definition){
|
||||
if (typeof module !== "undefined" && module.exports) { module.exports = definition(); }
|
||||
else if (typeof define === "function" && define.amd) { define(definition); }
|
||||
else { context[name] = definition(name,context); }
|
||||
})("normalizeSelector",this,function DEF(name,context){
|
||||
"use strict";
|
||||
|
||||
function normalizeSelector(sel) {
|
||||
|
||||
// save unmatched text, if any
|
||||
function saveUnmatched() {
|
||||
if (unmatched) {
|
||||
// whitespace needed after combinator?
|
||||
if (tokens.length > 0 &&
|
||||
/^[~+>]$/.test(tokens[tokens.length-1])
|
||||
) {
|
||||
tokens.push(" ");
|
||||
}
|
||||
|
||||
// save unmatched text
|
||||
tokens.push(unmatched);
|
||||
}
|
||||
}
|
||||
|
||||
var tokens = [], match, unmatched, regex, state = [0],
|
||||
next_match_idx = 0, prev_match_idx,
|
||||
not_escaped_pattern = /(?:[^\\]|(?:^|[^\\])(?:\\\\)+)$/,
|
||||
whitespace_pattern = /^\s+$/,
|
||||
attribute_nonspecial_pattern = /[^\s=~!^|$*\[\]\(\)]{2}/,
|
||||
state_patterns = [
|
||||
/\s+|\/\*|["'>~+\[\(]/g, // general
|
||||
/\s+|\/\*|["'\[\]\(\)]/g, // [..] set
|
||||
/\s+|\/\*|["'\[\]\(\)]/g, // (..) set
|
||||
null, // string literal (placeholder)
|
||||
/\*\//g // comment
|
||||
]
|
||||
;
|
||||
|
||||
sel = sel.trim();
|
||||
|
||||
while (true) {
|
||||
unmatched = "";
|
||||
|
||||
regex = state_patterns[state[state.length-1]];
|
||||
|
||||
regex.lastIndex = next_match_idx;
|
||||
match = regex.exec(sel);
|
||||
|
||||
// matched text to process?
|
||||
if (match) {
|
||||
prev_match_idx = next_match_idx;
|
||||
next_match_idx = regex.lastIndex;
|
||||
|
||||
// collect the previous string chunk not matched before this token
|
||||
if (prev_match_idx < next_match_idx - match[0].length) {
|
||||
unmatched = sel.substring(prev_match_idx,next_match_idx - match[0].length);
|
||||
}
|
||||
|
||||
// need to force a space (possibly skipped
|
||||
// previously by the parser)?
|
||||
if (
|
||||
state[state.length-1] === 1 &&
|
||||
attribute_nonspecial_pattern.test(
|
||||
tokens[tokens.length-1].substr(-1) +
|
||||
unmatched.charAt(0)
|
||||
)
|
||||
) {
|
||||
tokens.push(" ");
|
||||
}
|
||||
|
||||
// general, [ ] pair, ( ) pair?
|
||||
if (state[state.length-1] < 3) {
|
||||
saveUnmatched();
|
||||
|
||||
// starting a [ ] pair?
|
||||
if (match[0] === "[") {
|
||||
state.push(1);
|
||||
}
|
||||
// starting a ( ) pair?
|
||||
else if (match[0] === "(") {
|
||||
state.push(2);
|
||||
}
|
||||
// starting a string literal?
|
||||
else if (/^["']$/.test(match[0])) {
|
||||
state.push(3);
|
||||
state_patterns[3] = new RegExp(match[0],"g");
|
||||
}
|
||||
// starting a comment?
|
||||
else if (match[0] === "/*") {
|
||||
state.push(4);
|
||||
}
|
||||
// ending a [ ] or ( ) pair?
|
||||
else if (/^[\]\)]$/.test(match[0]) && state.length > 0) {
|
||||
state.pop();
|
||||
}
|
||||
// handling whitespace or a combinator?
|
||||
else if (/^(?:\s+|[~+>])$/.test(match[0])) {
|
||||
// need to insert whitespace before?
|
||||
if (tokens.length > 0 &&
|
||||
!whitespace_pattern.test(tokens[tokens.length-1]) &&
|
||||
state[state.length-1] === 0
|
||||
) {
|
||||
// add normalized whitespace
|
||||
tokens.push(" ");
|
||||
}
|
||||
|
||||
// whitespace token we can skip?
|
||||
if (whitespace_pattern.test(match[0])) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// save matched text
|
||||
tokens.push(match[0]);
|
||||
}
|
||||
// otherwise, string literal or comment
|
||||
else {
|
||||
// save unmatched text
|
||||
tokens[tokens.length-1] += unmatched;
|
||||
|
||||
// unescaped terminator to string literal or comment?
|
||||
if (not_escaped_pattern.test(tokens[tokens.length-1])) {
|
||||
// comment terminator?
|
||||
if (state[state.length-1] === 4) {
|
||||
// ok to drop comment?
|
||||
if (tokens.length < 2 ||
|
||||
whitespace_pattern.test(tokens[tokens.length-2])
|
||||
) {
|
||||
tokens.pop();
|
||||
}
|
||||
// otherwise, turn comment into whitespace
|
||||
else {
|
||||
tokens[tokens.length-1] = " ";
|
||||
}
|
||||
|
||||
// handled already
|
||||
match[0] = "";
|
||||
}
|
||||
|
||||
state.pop();
|
||||
}
|
||||
|
||||
// append matched text to existing token
|
||||
tokens[tokens.length-1] += match[0];
|
||||
}
|
||||
}
|
||||
// otherwise, end of processing (no more matches)
|
||||
else {
|
||||
unmatched = sel.substr(next_match_idx);
|
||||
saveUnmatched();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return tokens.join("").trim();
|
||||
}
|
||||
|
||||
return normalizeSelector;
|
||||
});
|
||||
|
85
node_modules/normalize-selector/package.json
generated
vendored
Normal file
85
node_modules/normalize-selector/package.json
generated
vendored
Normal file
@@ -0,0 +1,85 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"normalize-selector@^0.2.0",
|
||||
"/Users/pmarsceill/_projects/just-the-docs/node_modules/stylelint"
|
||||
]
|
||||
],
|
||||
"_from": "normalize-selector@>=0.2.0 <0.3.0",
|
||||
"_id": "normalize-selector@0.2.0",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/normalize-selector",
|
||||
"_nodeVersion": "2.2.1",
|
||||
"_npmUser": {
|
||||
"email": "getify@gmail.com",
|
||||
"name": "getify"
|
||||
},
|
||||
"_npmVersion": "2.11.0",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "normalize-selector",
|
||||
"raw": "normalize-selector@^0.2.0",
|
||||
"rawSpec": "^0.2.0",
|
||||
"scope": null,
|
||||
"spec": ">=0.2.0 <0.3.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/stylelint"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/normalize-selector/-/normalize-selector-0.2.0.tgz",
|
||||
"_shasum": "d0b145eb691189c63a78d201dc4fdb1293ef0c03",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "normalize-selector@^0.2.0",
|
||||
"_where": "/Users/pmarsceill/_projects/just-the-docs/node_modules/stylelint",
|
||||
"author": {
|
||||
"email": "getify@gmail.com",
|
||||
"name": "Kyle Simpson"
|
||||
},
|
||||
"bugs": {
|
||||
"email": "getify@gmail.com",
|
||||
"url": "https://github.com/getify/normalize-selector/issues"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "David Kaye",
|
||||
"url": "https://github.com/dfkaye"
|
||||
}
|
||||
],
|
||||
"dependencies": {},
|
||||
"description": "Normalize CSS Selectors",
|
||||
"devDependencies": {
|
||||
"assertik": "^1.0.0",
|
||||
"mocha": "^2.2.5"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "d0b145eb691189c63a78d201dc4fdb1293ef0c03",
|
||||
"tarball": "https://registry.npmjs.org/normalize-selector/-/normalize-selector-0.2.0.tgz"
|
||||
},
|
||||
"gitHead": "06b9028ca703fa7512d257c4ef3979dd91f4279a",
|
||||
"homepage": "http://github.com/getify/normalize-selector",
|
||||
"keywords": [
|
||||
"CSS"
|
||||
],
|
||||
"license": "MIT",
|
||||
"main": "./lib/normalize-selector.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "getify",
|
||||
"email": "getify@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "normalize-selector",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/getify/normalize-selector.git"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "node ./test/mocha/node-suite.js"
|
||||
},
|
||||
"version": "0.2.0"
|
||||
}
|
23
node_modules/normalize-selector/test/mocha/browser-suite.html
generated
vendored
Normal file
23
node_modules/normalize-selector/test/mocha/browser-suite.html
generated
vendored
Normal file
@@ -0,0 +1,23 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>mocha browser-suite: normalize-selector</title>
|
||||
<link rel="stylesheet" href="../../node_modules/mocha/mocha.css" />
|
||||
</head>
|
||||
<body>
|
||||
<div id="mocha"></div>
|
||||
<script src="../../lib/normalize-selector.js"></script>
|
||||
<script src="../../node_modules/assertik/assertik.js"></script>
|
||||
<script src="../../node_modules/mocha/mocha.js"></script>
|
||||
<script>mocha.setup('qunit')</script>
|
||||
|
||||
<!-- get tests and start -->
|
||||
<script src="./suite.js"></script>
|
||||
<script>
|
||||
mocha.checkLeaks();
|
||||
mocha.globals(['boilerplate']); // watch our boilerplate function
|
||||
mocha.run();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
18
node_modules/normalize-selector/test/mocha/node-suite.js
generated
vendored
Normal file
18
node_modules/normalize-selector/test/mocha/node-suite.js
generated
vendored
Normal file
@@ -0,0 +1,18 @@
|
||||
// test/mocha/node-suite.js
|
||||
|
||||
// This runs with mocha programmatically rather than from the command line.
|
||||
// how-to-with-comments taken from https://github.com/itaylor/qunit-mocha-ui
|
||||
|
||||
//Load mocha
|
||||
var Mocha = require("mocha");
|
||||
|
||||
//Tell mocha to use the interface.
|
||||
var mocha = new Mocha({ui:"qunit", reporter:"spec"});
|
||||
|
||||
//Add your test files
|
||||
mocha.addFile("./test/mocha/suite.js");
|
||||
|
||||
//Run your tests
|
||||
mocha.run(function(failures){
|
||||
process.exit(failures);
|
||||
});
|
117
node_modules/normalize-selector/test/mocha/suite.js
generated
vendored
Normal file
117
node_modules/normalize-selector/test/mocha/suite.js
generated
vendored
Normal file
@@ -0,0 +1,117 @@
|
||||
// mocha/suite.js for normalize-selector.js
|
||||
|
||||
var normalizeSelector;
|
||||
var assert;
|
||||
|
||||
if (typeof require == 'function') {
|
||||
// enable to re-use in a browser without require.js
|
||||
normalizeSelector = require('../../lib/normalize-selector.js');
|
||||
assert = require('assertik');
|
||||
} else {
|
||||
assert = window.assertik;
|
||||
}
|
||||
|
||||
suite('normalizeSelector');
|
||||
|
||||
test('should be function', function () {
|
||||
assert.equal(typeof normalizeSelector, 'function', 'wrong type');
|
||||
});
|
||||
|
||||
test('should normalize BIG SELECTOR', function () {
|
||||
var selector = "*~*>*.foo[ href *= \"/\" ]:hover>*[ data-foo = " +
|
||||
"\"bar\" ]:focus+*.baz::after";
|
||||
var expected = "* ~ * > *.foo[href*=\"/\"]:hover > *[data-foo=\"bar\"]:" +
|
||||
"focus + *.baz::after";
|
||||
assert.equal(normalizeSelector(selector), expected);
|
||||
});
|
||||
|
||||
test('should return optimized selector with no change', function () {
|
||||
assert.equal(normalizeSelector("#foo .bar"), "#foo .bar");
|
||||
});
|
||||
|
||||
test('should trim whitespace', function () {
|
||||
assert.equal(normalizeSelector(" #foo .bar "), "#foo .bar");
|
||||
});
|
||||
|
||||
test('should separate between combinators', function () {
|
||||
assert.equal(normalizeSelector("#foo>.bar+.baz"), "#foo > .bar + .baz");
|
||||
});
|
||||
|
||||
test('should not separate concatenated classes', function () {
|
||||
assert.equal(normalizeSelector("#foo.bar.baz"), "#foo.bar.baz");
|
||||
});
|
||||
|
||||
test('should normalize asterisks', function () {
|
||||
var selector = " *.class[ data * = 'data' ] ";
|
||||
assert.equal(normalizeSelector(selector), "*.class[data*='data']");
|
||||
});
|
||||
|
||||
test('should remove comments', function () {
|
||||
assert.equal(normalizeSelector(".e1 /* c2 */ .e2"), ".e1 .e2");
|
||||
assert.equal(normalizeSelector(" /*c1*/ .e1/*c2*/.e2 /*c3*/ .e3 /*c4*/ "), ".e1 .e2 .e3");
|
||||
assert.equal(normalizeSelector(" /*c1*/ .e1/*c2*/.e2 /*c3*/ .e3 "), ".e1 .e2 .e3");
|
||||
assert.equal(normalizeSelector("/*c1*/.e1/*c2*/.e2 /*c3*/ .e3"), ".e1 .e2 .e3");
|
||||
assert.equal(normalizeSelector(".e1/*c2*/.e2 /*c3*/ .e3"), ".e1 .e2 .e3");
|
||||
});
|
||||
|
||||
test('should replace comments with single whitespace', function () {
|
||||
assert.equal(normalizeSelector("tag/* c2 */tag"), "tag tag");
|
||||
});
|
||||
|
||||
test('should normalize parentheses', function() {
|
||||
var selector = "((a ) (b(c ) ) d )>*[ data-foo = \"bar\" ]";
|
||||
var expected = "((a)(b(c))d) > *[data-foo=\"bar\"]";
|
||||
assert.equal(normalizeSelector(selector), expected);
|
||||
});
|
||||
|
||||
test('should normalize @-rule parentheses', function () {
|
||||
var selector = "@media screen and ( color ), projection and (color )";
|
||||
var expected = "@media screen and (color), projection and (color)";
|
||||
assert.equal(normalizeSelector(selector), expected);
|
||||
});
|
||||
|
||||
test('should normalize @-rules with compound parentheses', function () {
|
||||
var selector = "@media handheld and ( min-width : 20em ), screen " +
|
||||
"and ( min-width: 20em )";
|
||||
var expected = "@media handheld and (min-width:20em), screen and " +
|
||||
"(min-width:20em)";
|
||||
assert.equal(normalizeSelector(selector), expected);
|
||||
});
|
||||
|
||||
test('should normalize @-rules with operations', function () {
|
||||
var selector = "@media screen and ( device-aspect-ratio : 2560 / 1440 )";
|
||||
var expected = "@media screen and (device-aspect-ratio:2560/1440)";
|
||||
assert.equal(normalizeSelector(selector), expected);
|
||||
});
|
||||
|
||||
test('should normalize descriptors', function () {
|
||||
var selector = "@counter-style triangle";
|
||||
assert.equal(normalizeSelector(selector), "@counter-style triangle");
|
||||
});
|
||||
|
||||
test('should normalize case-insensitivity attribute selector', function () {
|
||||
assert.equal(normalizeSelector("[ att ~= val i ]"), "[att~=val i]");
|
||||
assert.equal(normalizeSelector("#foo[ a = \"b\" i ]"), "#foo[a=\"b\" i]");
|
||||
});
|
||||
|
||||
test('should normalize namespaced attribute selector', function () {
|
||||
var selector = ' unit[ sh | quantity = "200" ] ';
|
||||
var expected = 'unit[sh|quantity="200"]';
|
||||
assert.equal(normalizeSelector(selector), expected);
|
||||
});
|
||||
|
||||
test('should normalize pseudo-classes', function () {
|
||||
var selector = " :nth-last-of-type( ) ";
|
||||
assert.equal(normalizeSelector(selector), ":nth-last-of-type()");
|
||||
});
|
||||
|
||||
test('should normalize pseudo-elements', function () {
|
||||
var selector = " ::nth-fragment( ) ";
|
||||
assert.equal(normalizeSelector(selector), "::nth-fragment()");
|
||||
});
|
||||
|
||||
test('should normalize backslashes', function () {
|
||||
var selector = "#foo[ a = \" b \\\" c\\\\\" ]";
|
||||
var expected = "#foo[a=\" b \\\" c\\\\\"]";
|
||||
assert.equal(normalizeSelector(selector), expected);
|
||||
});
|
49
node_modules/normalize-selector/tests.js
generated
vendored
Normal file
49
node_modules/normalize-selector/tests.js
generated
vendored
Normal file
@@ -0,0 +1,49 @@
|
||||
var normalize = require("./lib/normalize-selector.js");
|
||||
|
||||
var tests = {
|
||||
/*test*/"#foo .bar":
|
||||
/*expected*/"#foo .bar",
|
||||
/*test*/" #foo .bar ":
|
||||
/*expected*/"#foo .bar",
|
||||
/*test*/"#foo>.bar":
|
||||
/*expected*/"#foo > .bar",
|
||||
/*test*/" unit[ sh | quantity = \"200\" ] ":
|
||||
/*expected*/"unit[sh|quantity=\"200\"]",
|
||||
/*test*/"*~*>*.foo[ href *= \"/\" ]:hover>*[ data-foo = \"bar\" ]:focus+*.baz::after":
|
||||
/*expected*/"* ~ * > *.foo[href*=\"/\"]:hover > *[data-foo=\"bar\"]:focus + *.baz::after",
|
||||
/*test*/"@media screen and ( color ), projection and ( color )":
|
||||
/*expected*/"@media screen and (color), projection and (color)",
|
||||
/*test*/"@media handheld and ( min-width : 20em ), screen and ( min-width: 20em )":
|
||||
/*expected*/"@media handheld and (min-width:20em), screen and (min-width:20em)",
|
||||
/*test*/"@media screen and ( device-aspect-ratio : 2560 / 1440 )":
|
||||
/*expected*/"@media screen and (device-aspect-ratio:2560/1440)",
|
||||
/*test*/"((a ) (b(c ) ) d )>*[ data-foo = \"bar\" ]":
|
||||
/*expected*/"((a)(b(c))d) > *[data-foo=\"bar\"]",
|
||||
/*test*/"#foo[ a = \" b \\\" c\\\\\" ]":
|
||||
/*expected*/"#foo[a=\" b \\\" c\\\\\"]",
|
||||
/*test*/"#foo[ a = \"b\" i ]":
|
||||
/*expected*/"#foo[a=\"b\" i]",
|
||||
/*test*/" /*c1*/ .e1/*c2*/.e2 /*c3*/ .e3 /*c4*/ ":
|
||||
/*expected*/".e1 .e2 .e3",
|
||||
/*test*/" /*c1*/ .e1/*c2*/.e2 /*c3*/ .e3 ":
|
||||
/*expected*/".e1 .e2 .e3",
|
||||
/*test*/" /*c1*/ .e1/*c2*/.e2 /*c3*/ .e3":
|
||||
/*expected*/".e1 .e2 .e3",
|
||||
/*test*/"/*c1*/.e1/*c2*/.e2 /*c3*/ .e3":
|
||||
/*expected*/".e1 .e2 .e3",
|
||||
/*test*/".e1/*c2*/.e2 /*c3*/ .e3":
|
||||
/*expected*/".e1 .e2 .e3"
|
||||
};
|
||||
|
||||
var test, tmp;
|
||||
for (test in tests) {
|
||||
if ((tmp = normalize(test)) && tmp === tests[test]) {
|
||||
console.log("PASSED: " + test + " (" + tmp + ")");
|
||||
}
|
||||
else {
|
||||
console.log("FAILED.\n Expected: " + tests[test] + "\n Received: " + tmp);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
console.log("Tests done.");
|
Reference in New Issue
Block a user