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:
21
node_modules/postcss-resolve-nested-selector/LICENSE
generated
vendored
Normal file
21
node_modules/postcss-resolve-nested-selector/LICENSE
generated
vendored
Normal file
@@ -0,0 +1,21 @@
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2016 David Clark
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
65
node_modules/postcss-resolve-nested-selector/README.md
generated
vendored
Normal file
65
node_modules/postcss-resolve-nested-selector/README.md
generated
vendored
Normal file
@@ -0,0 +1,65 @@
|
||||
# postcss-resolve-nested-selector
|
||||
|
||||
[](https://travis-ci.org/davidtheclark/postcss-resolve-nested-selector)
|
||||
|
||||
Given a (nested) selector in a PostCSS AST, return an array of resolved selectors.
|
||||
|
||||
Tested to work with the syntax of
|
||||
[postcss-nested](https://github.com/postcss/postcss-nested)
|
||||
and [postcss-nesting](https://github.com/jonathantneal/postcss-nesting).
|
||||
Should also work with SCSS and Less syntax. If you'd like to help out by
|
||||
adding some automated tests for those, that'd be swell. In fact, if you'd
|
||||
like to add any automated tests, you are a winner!
|
||||
|
||||
## API
|
||||
|
||||
`resolveNestedSelector(selector, node)`
|
||||
|
||||
Returns an array of selectors resolved from `selector`.
|
||||
|
||||
For example, given this JS:
|
||||
|
||||
```js
|
||||
var resolvedNestedSelector = require('postcss-resolve-nested-selector');
|
||||
postcssRoot.eachRule(function(rule) {
|
||||
rule.selectors.forEach(function(selector) {
|
||||
console.log(resolvedNestedSelector(selector, rule));
|
||||
});
|
||||
});
|
||||
```
|
||||
|
||||
And the following CSS:
|
||||
|
||||
```scss
|
||||
.foo {
|
||||
.bar {
|
||||
color: pink;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This should log:
|
||||
|
||||
```
|
||||
['.foo']
|
||||
['.foo .bar']
|
||||
```
|
||||
|
||||
Or with this CSS:
|
||||
|
||||
```scss
|
||||
.foo {
|
||||
.bar &,
|
||||
a {
|
||||
color: pink;
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
This should log:
|
||||
|
||||
```
|
||||
['.foo']
|
||||
['.bar .foo']
|
||||
['.foo a']
|
||||
```
|
25
node_modules/postcss-resolve-nested-selector/index.js
generated
vendored
Normal file
25
node_modules/postcss-resolve-nested-selector/index.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
module.exports = function resolveNestedSelector(selector, node) {
|
||||
var parent = node.parent;
|
||||
var parentIsNestAtRule = parent.type === 'atrule' && parent.name === 'nest';
|
||||
|
||||
if (parent.type === 'root') return [selector];
|
||||
if (parent.type !== 'rule' && !parentIsNestAtRule) return resolveNestedSelector(selector, parent);
|
||||
|
||||
var parentSelectors = (parentIsNestAtRule)
|
||||
? parent.params.split(',').map(function(s) { return s.trim(); })
|
||||
: parent.selectors;
|
||||
|
||||
var resolvedSelectors = parentSelectors.reduce(function(result, parentSelector) {
|
||||
if (selector.indexOf('&') !== -1) {
|
||||
var newlyResolvedSelectors = resolveNestedSelector(parentSelector, parent).map(function(resolvedParentSelector) {
|
||||
return selector.replace(/&/g, resolvedParentSelector);
|
||||
});
|
||||
return result.concat(newlyResolvedSelectors);
|
||||
}
|
||||
|
||||
var combinedSelector = [ parentSelector, selector ].join(' ');
|
||||
return result.concat(resolveNestedSelector(combinedSelector, parent));
|
||||
}, []);
|
||||
|
||||
return resolvedSelectors;
|
||||
}
|
75
node_modules/postcss-resolve-nested-selector/package.json
generated
vendored
Normal file
75
node_modules/postcss-resolve-nested-selector/package.json
generated
vendored
Normal file
@@ -0,0 +1,75 @@
|
||||
{
|
||||
"_args": [
|
||||
[
|
||||
"postcss-resolve-nested-selector@^0.1.1",
|
||||
"/Users/pmarsceill/_projects/just-the-docs/node_modules/stylelint"
|
||||
]
|
||||
],
|
||||
"_from": "postcss-resolve-nested-selector@>=0.1.1 <0.2.0",
|
||||
"_id": "postcss-resolve-nested-selector@0.1.1",
|
||||
"_inCache": true,
|
||||
"_installable": true,
|
||||
"_location": "/postcss-resolve-nested-selector",
|
||||
"_nodeVersion": "5.6.0",
|
||||
"_npmOperationalInternal": {
|
||||
"host": "packages-9-west.internal.npmjs.com",
|
||||
"tmp": "tmp/postcss-resolve-nested-selector-0.1.1.tgz_1455858742856_0.8599636028520763"
|
||||
},
|
||||
"_npmUser": {
|
||||
"email": "david.dave.clark@gmail.com",
|
||||
"name": "davidtheclark"
|
||||
},
|
||||
"_npmVersion": "3.7.2",
|
||||
"_phantomChildren": {},
|
||||
"_requested": {
|
||||
"name": "postcss-resolve-nested-selector",
|
||||
"raw": "postcss-resolve-nested-selector@^0.1.1",
|
||||
"rawSpec": "^0.1.1",
|
||||
"scope": null,
|
||||
"spec": ">=0.1.1 <0.2.0",
|
||||
"type": "range"
|
||||
},
|
||||
"_requiredBy": [
|
||||
"/stylelint"
|
||||
],
|
||||
"_resolved": "https://registry.npmjs.org/postcss-resolve-nested-selector/-/postcss-resolve-nested-selector-0.1.1.tgz",
|
||||
"_shasum": "29ccbc7c37dedfac304e9fff0bf1596b3f6a0e4e",
|
||||
"_shrinkwrap": null,
|
||||
"_spec": "postcss-resolve-nested-selector@^0.1.1",
|
||||
"_where": "/Users/pmarsceill/_projects/just-the-docs/node_modules/stylelint",
|
||||
"author": {
|
||||
"name": "David Clark"
|
||||
},
|
||||
"dependencies": {},
|
||||
"description": "Resolve a nested selector in a PostCSS AST",
|
||||
"devDependencies": {
|
||||
"ava": "0.12.0",
|
||||
"postcss": "5.0.16",
|
||||
"postcss-nested": "1.0.0",
|
||||
"postcss-nesting": "2.2.0"
|
||||
},
|
||||
"directories": {},
|
||||
"dist": {
|
||||
"shasum": "29ccbc7c37dedfac304e9fff0bf1596b3f6a0e4e",
|
||||
"tarball": "https://registry.npmjs.org/postcss-resolve-nested-selector/-/postcss-resolve-nested-selector-0.1.1.tgz"
|
||||
},
|
||||
"files": [
|
||||
"index.js"
|
||||
],
|
||||
"gitHead": "d3f0898568ea8182a766b2fdaae25bae636b6c67",
|
||||
"license": "MIT",
|
||||
"main": "index.js",
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "davidtheclark",
|
||||
"email": "david.dave.clark@gmail.com"
|
||||
}
|
||||
],
|
||||
"name": "postcss-resolve-nested-selector",
|
||||
"optionalDependencies": {},
|
||||
"readme": "ERROR: No README data found!",
|
||||
"scripts": {
|
||||
"test": "ava test/*-test.js"
|
||||
},
|
||||
"version": "0.1.1"
|
||||
}
|
Reference in New Issue
Block a user