postcss-selector-parser
Advanced tools
Comparing version
@@ -193,3 +193,5 @@ # API Documentation | ||
`attribute`, `class`, `combinator`, `comment`, `id`, `nesting`, `pseudo`, | ||
`root`, `selector`, `string`, `tag`, or `universal`. | ||
`root`, `selector`, `string`, `tag`, or `universal`. Note that for convenience, | ||
these constants are exposed on the main `parser` as uppercased keys. So for | ||
example you can get `id` by querying `parser.ID`. | ||
@@ -196,0 +198,0 @@ ```js |
@@ -0,1 +1,6 @@ | ||
# 2.1.0 | ||
* Added: Use string constants for all node types & expose them on the main | ||
parser instance (thanks to @Aweary). | ||
# 2.0.0 | ||
@@ -2,0 +7,0 @@ |
@@ -57,2 +57,8 @@ 'use strict'; | ||
var _types = require('./selectors/types'); | ||
var types = _interopRequireWildcard(_types); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -67,43 +73,32 @@ | ||
}; | ||
parser.className = function (opts) { | ||
return new _className2.default(opts); | ||
}; | ||
parser.combinator = function (opts) { | ||
return new _combinator2.default(opts); | ||
}; | ||
parser.comment = function (opts) { | ||
return new _comment2.default(opts); | ||
}; | ||
parser.id = function (opts) { | ||
return new _id2.default(opts); | ||
}; | ||
parser.nesting = function (opts) { | ||
return new _nesting2.default(opts); | ||
}; | ||
parser.pseudo = function (opts) { | ||
return new _pseudo2.default(opts); | ||
}; | ||
parser.root = function (opts) { | ||
return new _root2.default(opts); | ||
}; | ||
parser.selector = function (opts) { | ||
return new _selector2.default(opts); | ||
}; | ||
parser.string = function (opts) { | ||
return new _string2.default(opts); | ||
}; | ||
parser.tag = function (opts) { | ||
return new _tag2.default(opts); | ||
}; | ||
parser.universal = function (opts) { | ||
@@ -113,3 +108,10 @@ return new _universal2.default(opts); | ||
Object.keys(types).forEach(function (type) { | ||
if (type === '__esModule') { | ||
return; | ||
} | ||
parser[type] = types[type]; | ||
}); | ||
exports.default = parser; | ||
module.exports = exports['default']; |
@@ -75,2 +75,8 @@ 'use strict'; | ||
var _types = require('./selectors/types'); | ||
var types = _interopRequireWildcard(_types); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -261,3 +267,3 @@ | ||
var last = this.current.last; | ||
if (last && last.type === 'pseudo') { | ||
if (last && last.type === types.PSEUDO) { | ||
var selector = new _selector2.default(); | ||
@@ -264,0 +270,0 @@ var cache = this.current; |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _types = require('./types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -26,3 +28,3 @@ | ||
_this.type = 'attribute'; | ||
_this.type = _types.ATTRIBUTE; | ||
_this.raws = {}; | ||
@@ -29,0 +31,0 @@ return _this; |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _types = require('./types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -26,3 +28,3 @@ | ||
_this.type = 'class'; | ||
_this.type = _types.CLASS; | ||
return _this; | ||
@@ -29,0 +31,0 @@ } |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _types = require('./types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -26,3 +28,3 @@ | ||
_this.type = 'combinator'; | ||
_this.type = _types.COMBINATOR; | ||
return _this; | ||
@@ -29,0 +31,0 @@ } |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _types = require('./types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -26,3 +28,3 @@ | ||
_this.type = 'comment'; | ||
_this.type = _types.COMMENT; | ||
return _this; | ||
@@ -29,0 +31,0 @@ } |
@@ -11,2 +11,8 @@ 'use strict'; | ||
var _types = require('./types'); | ||
var types = _interopRequireWildcard(_types); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -181,3 +187,3 @@ | ||
return this.walk(function (selector) { | ||
if (selector.type === 'attribute') { | ||
if (selector.type === types.ATTRIBUTE) { | ||
return callback.call(_this2, selector); | ||
@@ -192,3 +198,3 @@ } | ||
return this.walk(function (selector) { | ||
if (selector.type === 'class') { | ||
if (selector.type === types.CLASS) { | ||
return callback.call(_this3, selector); | ||
@@ -203,3 +209,3 @@ } | ||
return this.walk(function (selector) { | ||
if (selector.type === 'combinator') { | ||
if (selector.type === types.COMBINATOR) { | ||
return callback.call(_this4, selector); | ||
@@ -214,3 +220,3 @@ } | ||
return this.walk(function (selector) { | ||
if (selector.type === 'comment') { | ||
if (selector.type === types.COMMENT) { | ||
return callback.call(_this5, selector); | ||
@@ -225,3 +231,3 @@ } | ||
return this.walk(function (selector) { | ||
if (selector.type === 'id') { | ||
if (selector.type === types.ID) { | ||
return callback.call(_this6, selector); | ||
@@ -236,3 +242,3 @@ } | ||
return this.walk(function (selector) { | ||
if (selector.type === 'nesting') { | ||
if (selector.type === types.NESTING) { | ||
return callback.call(_this7, selector); | ||
@@ -247,3 +253,3 @@ } | ||
return this.walk(function (selector) { | ||
if (selector.type === 'pseudo') { | ||
if (selector.type === types.PSEUDO) { | ||
return callback.call(_this8, selector); | ||
@@ -258,3 +264,3 @@ } | ||
return this.walk(function (selector) { | ||
if (selector.type === 'tag') { | ||
if (selector.type === types.TAG) { | ||
return callback.call(_this9, selector); | ||
@@ -269,3 +275,3 @@ } | ||
return this.walk(function (selector) { | ||
if (selector.type === 'universal') { | ||
if (selector.type === types.UNIVERSAL) { | ||
return callback.call(_this10, selector); | ||
@@ -272,0 +278,0 @@ } |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _types = require('./types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -26,3 +28,3 @@ | ||
_this.type = 'id'; | ||
_this.type = _types.ID; | ||
return _this; | ||
@@ -29,0 +31,0 @@ } |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _types = require('./types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -26,3 +28,3 @@ | ||
_this.type = 'nesting'; | ||
_this.type = _types.NESTING; | ||
_this.value = '&'; | ||
@@ -29,0 +31,0 @@ return _this; |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _types = require('./types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -26,3 +28,3 @@ | ||
_this.type = 'pseudo'; | ||
_this.type = _types.PSEUDO; | ||
return _this; | ||
@@ -29,0 +31,0 @@ } |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _types = require('./types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -26,3 +28,3 @@ | ||
_this.type = 'root'; | ||
_this.type = _types.ROOT; | ||
return _this; | ||
@@ -29,0 +31,0 @@ } |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _types = require('./types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -26,3 +28,3 @@ | ||
_this.type = 'selector'; | ||
_this.type = _types.SELECTOR; | ||
return _this; | ||
@@ -29,0 +31,0 @@ } |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _types = require('./types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -26,3 +28,3 @@ | ||
_this.type = 'string'; | ||
_this.type = _types.STRING; | ||
return _this; | ||
@@ -29,0 +31,0 @@ } |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _types = require('./types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -26,3 +28,3 @@ | ||
_this.type = 'tag'; | ||
_this.type = _types.TAG; | ||
return _this; | ||
@@ -29,0 +31,0 @@ } |
@@ -9,2 +9,4 @@ 'use strict'; | ||
var _types = require('./types'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
@@ -26,3 +28,3 @@ | ||
_this.type = 'universal'; | ||
_this.type = _types.UNIVERSAL; | ||
_this.value = '*'; | ||
@@ -29,0 +31,0 @@ return _this; |
@@ -10,2 +10,2 @@ "use strict"; | ||
}; | ||
module.exports = exports['default']; | ||
module.exports = exports["default"]; |
{ | ||
"name": "postcss-selector-parser", | ||
"version": "2.0.0", | ||
"version": "2.1.0", | ||
"devDependencies": { | ||
"ava": "^0.14.0", | ||
"ava": "^0.15.0", | ||
"babel-cli": "^6.4.0", | ||
"babel-core": "^6.4.0", | ||
"babel-plugin-add-module-exports": "^0.1.2", | ||
"babel-plugin-add-module-exports": "^0.2.0", | ||
"babel-plugin-precompile-charcodes": "^1.0.0", | ||
@@ -10,0 +10,0 @@ "babel-preset-es2015": "^6.3.13", |
87398
2.97%26
4%1513
2.72%