postcss-selector-parser
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -0,1 +1,5 @@ | ||
# 1.3.1 | ||
* Update flatten to v1.x (thanks to @shinnn). | ||
# 1.3.0 | ||
@@ -2,0 +6,0 @@ |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _processor = require('./processor'); | ||
@@ -13,95 +9,97 @@ | ||
var _selectorsAttribute = require('./selectors/attribute'); | ||
var _attribute = require('./selectors/attribute'); | ||
var _selectorsAttribute2 = _interopRequireDefault(_selectorsAttribute); | ||
var _attribute2 = _interopRequireDefault(_attribute); | ||
var _selectorsClassName = require('./selectors/className'); | ||
var _className = require('./selectors/className'); | ||
var _selectorsClassName2 = _interopRequireDefault(_selectorsClassName); | ||
var _className2 = _interopRequireDefault(_className); | ||
var _selectorsCombinator = require('./selectors/combinator'); | ||
var _combinator = require('./selectors/combinator'); | ||
var _selectorsCombinator2 = _interopRequireDefault(_selectorsCombinator); | ||
var _combinator2 = _interopRequireDefault(_combinator); | ||
var _selectorsComment = require('./selectors/comment'); | ||
var _comment = require('./selectors/comment'); | ||
var _selectorsComment2 = _interopRequireDefault(_selectorsComment); | ||
var _comment2 = _interopRequireDefault(_comment); | ||
var _selectorsId = require('./selectors/id'); | ||
var _id = require('./selectors/id'); | ||
var _selectorsId2 = _interopRequireDefault(_selectorsId); | ||
var _id2 = _interopRequireDefault(_id); | ||
var _selectorsPseudo = require('./selectors/pseudo'); | ||
var _pseudo = require('./selectors/pseudo'); | ||
var _selectorsPseudo2 = _interopRequireDefault(_selectorsPseudo); | ||
var _pseudo2 = _interopRequireDefault(_pseudo); | ||
var _selectorsRoot = require('./selectors/root'); | ||
var _root = require('./selectors/root'); | ||
var _selectorsRoot2 = _interopRequireDefault(_selectorsRoot); | ||
var _root2 = _interopRequireDefault(_root); | ||
var _selectorsSelector = require('./selectors/selector'); | ||
var _selector = require('./selectors/selector'); | ||
var _selectorsSelector2 = _interopRequireDefault(_selectorsSelector); | ||
var _selector2 = _interopRequireDefault(_selector); | ||
var _selectorsString = require('./selectors/string'); | ||
var _string = require('./selectors/string'); | ||
var _selectorsString2 = _interopRequireDefault(_selectorsString); | ||
var _string2 = _interopRequireDefault(_string); | ||
var _selectorsTag = require('./selectors/tag'); | ||
var _tag = require('./selectors/tag'); | ||
var _selectorsTag2 = _interopRequireDefault(_selectorsTag); | ||
var _tag2 = _interopRequireDefault(_tag); | ||
var _selectorsUniversal = require('./selectors/universal'); | ||
var _universal = require('./selectors/universal'); | ||
var _selectorsUniversal2 = _interopRequireDefault(_selectorsUniversal); | ||
var _universal2 = _interopRequireDefault(_universal); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var parser = function parser(processor) { | ||
return new _processor2['default'](processor); | ||
return new _processor2.default(processor); | ||
}; | ||
parser.attribute = function (opts) { | ||
return new _selectorsAttribute2['default'](opts); | ||
return new _attribute2.default(opts); | ||
}; | ||
parser.className = function (opts) { | ||
return new _selectorsClassName2['default'](opts); | ||
return new _className2.default(opts); | ||
}; | ||
parser.combinator = function (opts) { | ||
return new _selectorsCombinator2['default'](opts); | ||
return new _combinator2.default(opts); | ||
}; | ||
parser.comment = function (opts) { | ||
return new _selectorsComment2['default'](opts); | ||
return new _comment2.default(opts); | ||
}; | ||
parser.id = function (opts) { | ||
return new _selectorsId2['default'](opts); | ||
return new _id2.default(opts); | ||
}; | ||
parser.pseudo = function (opts) { | ||
return new _selectorsPseudo2['default'](opts); | ||
return new _pseudo2.default(opts); | ||
}; | ||
parser.root = function (opts) { | ||
return new _selectorsRoot2['default'](opts); | ||
return new _root2.default(opts); | ||
}; | ||
parser.selector = function (opts) { | ||
return new _selectorsSelector2['default'](opts); | ||
return new _selector2.default(opts); | ||
}; | ||
parser.string = function (opts) { | ||
return new _selectorsString2['default'](opts); | ||
return new _string2.default(opts); | ||
}; | ||
parser.tag = function (opts) { | ||
return new _selectorsTag2['default'](opts); | ||
return new _tag2.default(opts); | ||
}; | ||
parser.universal = function (opts) { | ||
return new _selectorsUniversal2['default'](opts); | ||
return new _universal2.default(opts); | ||
}; | ||
exports['default'] = parser; | ||
exports.default = parser; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
exports.__esModule = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _root = require('./selectors/root'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
var _root2 = _interopRequireDefault(_root); | ||
var _selectorsRoot = require('./selectors/root'); | ||
var _selector = require('./selectors/selector'); | ||
var _selectorsRoot2 = _interopRequireDefault(_selectorsRoot); | ||
var _selector2 = _interopRequireDefault(_selector); | ||
var _selectorsSelector = require('./selectors/selector'); | ||
var _className = require('./selectors/className'); | ||
var _selectorsSelector2 = _interopRequireDefault(_selectorsSelector); | ||
var _className2 = _interopRequireDefault(_className); | ||
var _selectorsClassName = require('./selectors/className'); | ||
var _comment = require('./selectors/comment'); | ||
var _selectorsClassName2 = _interopRequireDefault(_selectorsClassName); | ||
var _comment2 = _interopRequireDefault(_comment); | ||
var _selectorsComment = require('./selectors/comment'); | ||
var _id = require('./selectors/id'); | ||
var _selectorsComment2 = _interopRequireDefault(_selectorsComment); | ||
var _id2 = _interopRequireDefault(_id); | ||
var _selectorsId = require('./selectors/id'); | ||
var _tag = require('./selectors/tag'); | ||
var _selectorsId2 = _interopRequireDefault(_selectorsId); | ||
var _tag2 = _interopRequireDefault(_tag); | ||
var _selectorsTag = require('./selectors/tag'); | ||
var _string = require('./selectors/string'); | ||
var _selectorsTag2 = _interopRequireDefault(_selectorsTag); | ||
var _string2 = _interopRequireDefault(_string); | ||
var _selectorsString = require('./selectors/string'); | ||
var _pseudo = require('./selectors/pseudo'); | ||
var _selectorsString2 = _interopRequireDefault(_selectorsString); | ||
var _pseudo2 = _interopRequireDefault(_pseudo); | ||
var _selectorsPseudo = require('./selectors/pseudo'); | ||
var _attribute = require('./selectors/attribute'); | ||
var _selectorsPseudo2 = _interopRequireDefault(_selectorsPseudo); | ||
var _attribute2 = _interopRequireDefault(_attribute); | ||
var _selectorsAttribute = require('./selectors/attribute'); | ||
var _universal = require('./selectors/universal'); | ||
var _selectorsAttribute2 = _interopRequireDefault(_selectorsAttribute); | ||
var _universal2 = _interopRequireDefault(_universal); | ||
var _selectorsUniversal = require('./selectors/universal'); | ||
var _combinator = require('./selectors/combinator'); | ||
var _selectorsUniversal2 = _interopRequireDefault(_selectorsUniversal); | ||
var _combinator2 = _interopRequireDefault(_combinator); | ||
var _selectorsCombinator = require('./selectors/combinator'); | ||
var _selectorsCombinator2 = _interopRequireDefault(_selectorsCombinator); | ||
var _sortAscending = require('./sortAscending'); | ||
@@ -77,3 +71,7 @@ | ||
var Parser = (function () { | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var Parser = function () { | ||
function Parser(input) { | ||
@@ -84,9 +82,9 @@ _classCallCheck(this, Parser); | ||
this.position = 0; | ||
this.root = new _selectorsRoot2['default'](); | ||
this.root = new _root2.default(); | ||
var selectors = new _selectorsSelector2['default'](); | ||
var selectors = new _selector2.default(); | ||
this.root.append(selectors); | ||
this.current = selectors; | ||
this.tokens = (0, _tokenize2['default'])(input); | ||
this.tokens = (0, _tokenize2.default)(input); | ||
@@ -96,446 +94,429 @@ return this.loop(); | ||
_createClass(Parser, [{ | ||
key: 'attribute', | ||
value: function attribute() { | ||
var attribute = ''; | ||
var attr = undefined; | ||
var startingToken = this.currToken; | ||
Parser.prototype.attribute = function attribute() { | ||
var str = ''; | ||
var attr = undefined; | ||
var startingToken = this.currToken; | ||
this.position++; | ||
while (this.position < this.tokens.length && this.currToken[0] !== ']') { | ||
str += this.tokens[this.position][1]; | ||
this.position++; | ||
while (this.position < this.tokens.length && this.currToken[0] !== ']') { | ||
attribute += this.tokens[this.position][1]; | ||
this.position++; | ||
} | ||
if (this.position === this.tokens.length && ! ~attribute.indexOf(']')) { | ||
this.error('Expected a closing square bracket.'); | ||
} | ||
var parts = attribute.split(/((?:[*~^$|]?)=)/); | ||
var namespace = parts[0].split(/(\|)/g); | ||
var attributeProps = { | ||
operator: parts[1], | ||
value: parts[2], | ||
source: { | ||
start: { | ||
line: startingToken[2], | ||
column: startingToken[3] | ||
}, | ||
end: { | ||
line: this.currToken[2], | ||
column: this.currToken[3] | ||
} | ||
} | ||
if (this.position === this.tokens.length && ! ~str.indexOf(']')) { | ||
this.error('Expected a closing square bracket.'); | ||
} | ||
var parts = str.split(/((?:[*~^$|]?)=)/); | ||
var namespace = parts[0].split(/(\|)/g); | ||
var attributeProps = { | ||
operator: parts[1], | ||
value: parts[2], | ||
source: { | ||
start: { | ||
line: startingToken[2], | ||
column: startingToken[3] | ||
}, | ||
sourceIndex: startingToken[4] | ||
}; | ||
if (namespace.length > 1) { | ||
if (namespace[0] === '') { | ||
namespace[0] = true; | ||
end: { | ||
line: this.currToken[2], | ||
column: this.currToken[3] | ||
} | ||
attributeProps.attribute = namespace[2]; | ||
attributeProps.namespace = namespace[0]; | ||
} else { | ||
attributeProps.attribute = parts[0]; | ||
}, | ||
sourceIndex: startingToken[4] | ||
}; | ||
if (namespace.length > 1) { | ||
if (namespace[0] === '') { | ||
namespace[0] = true; | ||
} | ||
attr = new _selectorsAttribute2['default'](attributeProps); | ||
attributeProps.attribute = namespace[2]; | ||
attributeProps.namespace = namespace[0]; | ||
} else { | ||
attributeProps.attribute = parts[0]; | ||
} | ||
attr = new _attribute2.default(attributeProps); | ||
if (parts[2]) { | ||
var insensitive = parts[2].split(/(\s+i\s*?)$/); | ||
attr.value = insensitive[0]; | ||
if (insensitive[1]) { | ||
attr.insensitive = true; | ||
attr.raw.insensitive = insensitive[1]; | ||
} | ||
if (parts[2]) { | ||
var insensitive = parts[2].split(/(\s+i\s*?)$/); | ||
attr.value = insensitive[0]; | ||
if (insensitive[1]) { | ||
attr.insensitive = true; | ||
attr.raw.insensitive = insensitive[1]; | ||
} | ||
this.newNode(attr); | ||
this.position++; | ||
} | ||
}, { | ||
key: 'combinator', | ||
value: function combinator() { | ||
if (this.currToken[1] === '|') { | ||
return this.namespace(); | ||
} | ||
var combinator = new _selectorsCombinator2['default']({ | ||
value: '', | ||
source: { | ||
start: { | ||
line: this.currToken[2], | ||
column: this.currToken[3] | ||
}, | ||
end: { | ||
line: this.currToken[2], | ||
column: this.currToken[3] | ||
} | ||
this.newNode(attr); | ||
this.position++; | ||
}; | ||
Parser.prototype.combinator = function combinator() { | ||
if (this.currToken[1] === '|') { | ||
return this.namespace(); | ||
} | ||
var node = new _combinator2.default({ | ||
value: '', | ||
source: { | ||
start: { | ||
line: this.currToken[2], | ||
column: this.currToken[3] | ||
}, | ||
sourceIndex: this.currToken[4] | ||
}); | ||
while (this.position < this.tokens.length && this.currToken && (this.currToken[0] === 'space' || this.currToken[0] === 'combinator')) { | ||
if (this.nextToken && this.nextToken[0] === 'combinator') { | ||
combinator.spaces.before = this.currToken[1]; | ||
combinator.source.start.line = this.nextToken[2]; | ||
combinator.source.start.column = this.nextToken[3]; | ||
combinator.source.end.column = this.nextToken[3]; | ||
combinator.source.end.line = this.nextToken[2]; | ||
combinator.sourceIndex = this.nextToken[4]; | ||
} else if (this.prevToken && this.prevToken[0] === 'combinator') { | ||
combinator.spaces.after = this.currToken[1]; | ||
} else if (this.currToken[0] === 'space' || this.currToken[0] === 'combinator') { | ||
combinator.value = this.currToken[1]; | ||
end: { | ||
line: this.currToken[2], | ||
column: this.currToken[3] | ||
} | ||
this.position++; | ||
}, | ||
sourceIndex: this.currToken[4] | ||
}); | ||
while (this.position < this.tokens.length && this.currToken && (this.currToken[0] === 'space' || this.currToken[0] === 'combinator')) { | ||
if (this.nextToken && this.nextToken[0] === 'combinator') { | ||
node.spaces.before = this.currToken[1]; | ||
node.source.start.line = this.nextToken[2]; | ||
node.source.start.column = this.nextToken[3]; | ||
node.source.end.column = this.nextToken[3]; | ||
node.source.end.line = this.nextToken[2]; | ||
node.sourceIndex = this.nextToken[4]; | ||
} else if (this.prevToken && this.prevToken[0] === 'combinator') { | ||
node.spaces.after = this.currToken[1]; | ||
} else if (this.currToken[0] === 'space' || this.currToken[0] === 'combinator') { | ||
node.value = this.currToken[1]; | ||
} | ||
return this.newNode(combinator); | ||
this.position++; | ||
} | ||
}, { | ||
key: 'comma', | ||
value: function comma() { | ||
if (this.position === this.tokens.length - 1) { | ||
this.root.trailingComma = true; | ||
this.position++; | ||
return; | ||
} | ||
var selectors = new _selectorsSelector2['default'](); | ||
this.current.parent.append(selectors); | ||
this.current = selectors; | ||
return this.newNode(node); | ||
}; | ||
Parser.prototype.comma = function comma() { | ||
if (this.position === this.tokens.length - 1) { | ||
this.root.trailingComma = true; | ||
this.position++; | ||
return; | ||
} | ||
}, { | ||
key: 'comment', | ||
value: function comment() { | ||
var comment = new _selectorsComment2['default']({ | ||
value: this.currToken[1], | ||
source: { | ||
start: { | ||
line: this.currToken[2], | ||
column: this.currToken[3] | ||
}, | ||
end: { | ||
line: this.currToken[4], | ||
column: this.currToken[5] | ||
} | ||
var selectors = new _selector2.default(); | ||
this.current.parent.append(selectors); | ||
this.current = selectors; | ||
this.position++; | ||
}; | ||
Parser.prototype.comment = function comment() { | ||
var node = new _comment2.default({ | ||
value: this.currToken[1], | ||
source: { | ||
start: { | ||
line: this.currToken[2], | ||
column: this.currToken[3] | ||
}, | ||
sourceIndex: this.currToken[6] | ||
}); | ||
this.newNode(comment); | ||
end: { | ||
line: this.currToken[4], | ||
column: this.currToken[5] | ||
} | ||
}, | ||
sourceIndex: this.currToken[6] | ||
}); | ||
this.newNode(node); | ||
this.position++; | ||
}; | ||
Parser.prototype.error = function error(message) { | ||
throw new this.input.error(message); // eslint-disable-line new-cap | ||
}; | ||
Parser.prototype.namespace = function namespace() { | ||
var before = this.prevToken && this.prevToken[1] || true; | ||
if (this.nextToken[0] === 'word') { | ||
this.position++; | ||
return this.word(before); | ||
} else if (this.nextToken[0] === '*') { | ||
this.position++; | ||
return this.universal(before); | ||
} | ||
}, { | ||
key: 'error', | ||
value: function error(message) { | ||
throw new this.input.error(message); | ||
} | ||
}, { | ||
key: 'namespace', | ||
value: function namespace() { | ||
var before = this.prevToken && this.prevToken[1] || true; | ||
if (this.nextToken[0] === 'word') { | ||
this.position++; | ||
return this.word(before); | ||
} else if (this.nextToken[0] === '*') { | ||
this.position++; | ||
return this.universal(before); | ||
} | ||
} | ||
}, { | ||
key: 'parentheses', | ||
value: function parentheses() { | ||
var last = this.current.last; | ||
if (last && last.type === 'pseudo') { | ||
var selector = new _selectorsSelector2['default'](); | ||
var cache = this.current; | ||
last.append(selector); | ||
this.current = selector; | ||
var balanced = 1; | ||
this.position++; | ||
while (this.position < this.tokens.length && balanced) { | ||
if (this.currToken[0] === '(') { | ||
balanced++; | ||
} | ||
if (this.currToken[0] === ')') { | ||
balanced--; | ||
} | ||
if (balanced) { | ||
this.parse(); | ||
} else { | ||
selector.parent.source.end.line = this.currToken[2]; | ||
selector.parent.source.end.column = this.currToken[3]; | ||
this.position++; | ||
} | ||
}; | ||
Parser.prototype.parentheses = function parentheses() { | ||
var last = this.current.last; | ||
if (last && last.type === 'pseudo') { | ||
var selector = new _selector2.default(); | ||
var cache = this.current; | ||
last.append(selector); | ||
this.current = selector; | ||
var balanced = 1; | ||
this.position++; | ||
while (this.position < this.tokens.length && balanced) { | ||
if (this.currToken[0] === '(') { | ||
balanced++; | ||
} | ||
if (this.currToken[0] === ')') { | ||
balanced--; | ||
} | ||
if (balanced) { | ||
this.error('Expected closing parenthesis.'); | ||
} | ||
this.current = cache; | ||
} else { | ||
var balanced = 1; | ||
this.position++; | ||
last.value += '('; | ||
while (this.position < this.tokens.length && balanced) { | ||
if (this.currToken[0] === '(') { | ||
balanced++; | ||
} | ||
if (this.currToken[0] === ')') { | ||
balanced--; | ||
} | ||
last.value += this.currToken[1]; | ||
this.parse(); | ||
} else { | ||
selector.parent.source.end.line = this.currToken[2]; | ||
selector.parent.source.end.column = this.currToken[3]; | ||
this.position++; | ||
} | ||
if (balanced) { | ||
this.error('Expected closing parenthesis.'); | ||
} | ||
if (balanced) { | ||
this.error('Expected closing parenthesis.'); | ||
} | ||
this.current = cache; | ||
} else { | ||
var balanced = 1; | ||
this.position++; | ||
last.value += '('; | ||
while (this.position < this.tokens.length && balanced) { | ||
if (this.currToken[0] === '(') { | ||
balanced++; | ||
} | ||
} | ||
} | ||
}, { | ||
key: 'pseudo', | ||
value: function pseudo() { | ||
var _this = this; | ||
var pseudoStr = ''; | ||
var startingToken = this.currToken; | ||
while (this.currToken && this.currToken[0] === ':') { | ||
pseudoStr += this.currToken[1]; | ||
if (this.currToken[0] === ')') { | ||
balanced--; | ||
} | ||
last.value += this.currToken[1]; | ||
this.position++; | ||
} | ||
if (!this.currToken) { | ||
return this.error('Expected pseudo-class or pseudo-element'); | ||
if (balanced) { | ||
this.error('Expected closing parenthesis.'); | ||
} | ||
if (this.currToken[0] === 'word') { | ||
(function () { | ||
var pseudo = undefined; | ||
_this.splitWord(false, function (first, length) { | ||
pseudoStr += first; | ||
pseudo = new _selectorsPseudo2['default']({ | ||
value: pseudoStr, | ||
source: { | ||
start: { | ||
line: startingToken[2], | ||
column: startingToken[3] | ||
}, | ||
end: { | ||
line: _this.currToken[4], | ||
column: _this.currToken[5] | ||
} | ||
}, | ||
sourceIndex: startingToken[4] | ||
}); | ||
_this.newNode(pseudo); | ||
if (length > 1 && _this.nextToken && _this.nextToken[0] === '(') { | ||
_this.error('Misplaced parenthesis.'); | ||
} | ||
}); | ||
})(); | ||
} else { | ||
this.error('Unexpected "' + this.currToken[0] + '" found.'); | ||
} | ||
} | ||
}, { | ||
key: 'space', | ||
value: function space() { | ||
var token = this.currToken; | ||
// Handle space before and after the selector | ||
if (this.position === 0 || this.prevToken[0] === ',' || this.prevToken[0] === '(') { | ||
this.spaces = token[1]; | ||
this.position++; | ||
} else if (this.position === this.tokens.length - 1 || this.nextToken[0] === ',' || this.nextToken[0] === ')') { | ||
this.current.last.spaces.after = token[1]; | ||
this.position++; | ||
} else { | ||
this.combinator(); | ||
} | ||
} | ||
}, { | ||
key: 'string', | ||
value: function string() { | ||
var token = this.currToken; | ||
this.newNode(new _selectorsString2['default']({ | ||
value: this.currToken[1], | ||
source: { | ||
start: { | ||
line: token[2], | ||
column: token[3] | ||
}, | ||
end: { | ||
line: token[4], | ||
column: token[5] | ||
} | ||
}, | ||
sourceIndex: token[6] | ||
})); | ||
}; | ||
Parser.prototype.pseudo = function pseudo() { | ||
var _this = this; | ||
var pseudoStr = ''; | ||
var startingToken = this.currToken; | ||
while (this.currToken && this.currToken[0] === ':') { | ||
pseudoStr += this.currToken[1]; | ||
this.position++; | ||
} | ||
}, { | ||
key: 'universal', | ||
value: function universal(namespace) { | ||
var nextToken = this.nextToken; | ||
if (nextToken && nextToken[1] === '|') { | ||
this.position++; | ||
return this.namespace(); | ||
} | ||
this.newNode(new _selectorsUniversal2['default']({ | ||
value: this.currToken[1], | ||
source: { | ||
start: { | ||
line: this.currToken[2], | ||
column: this.currToken[3] | ||
}, | ||
end: { | ||
line: this.currToken[2], | ||
column: this.currToken[3] | ||
} | ||
}, | ||
sourceIndex: this.currToken[4] | ||
}), namespace); | ||
this.position++; | ||
if (!this.currToken) { | ||
return this.error('Expected pseudo-class or pseudo-element'); | ||
} | ||
}, { | ||
key: 'splitWord', | ||
value: function splitWord(namespace, firstCallback) { | ||
var _this2 = this; | ||
var nextToken = this.nextToken; | ||
var word = this.currToken[1]; | ||
while (nextToken && nextToken[0] === 'word') { | ||
this.position++; | ||
var current = this.currToken[1]; | ||
word += current; | ||
if (current.lastIndexOf('\\') === current.length - 1) { | ||
var next = this.nextToken; | ||
if (next && next[0] === 'space') { | ||
word += next[1]; | ||
this.position++; | ||
} | ||
} | ||
nextToken = this.nextToken; | ||
} | ||
var hasClass = (0, _indexesOf2['default'])(word, '.'); | ||
var hasId = (0, _indexesOf2['default'])(word, '#'); | ||
var indices = (0, _sortAscending2['default'])((0, _uniq2['default'])((0, _flatten2['default'])([[0], hasClass, hasId]))); | ||
indices.forEach(function (ind, i) { | ||
var index = indices[i + 1] || word.length; | ||
var value = word.slice(ind, index); | ||
if (i === 0 && firstCallback) { | ||
return firstCallback.call(_this2, value, indices.length); | ||
} | ||
var node = undefined; | ||
if (~hasClass.indexOf(ind)) { | ||
node = new _selectorsClassName2['default']({ | ||
value: value.slice(1), | ||
if (this.currToken[0] === 'word') { | ||
(function () { | ||
var pseudo = undefined; | ||
_this.splitWord(false, function (first, length) { | ||
pseudoStr += first; | ||
pseudo = new _pseudo2.default({ | ||
value: pseudoStr, | ||
source: { | ||
start: { | ||
line: _this2.currToken[2], | ||
column: _this2.currToken[3] + ind | ||
line: startingToken[2], | ||
column: startingToken[3] | ||
}, | ||
end: { | ||
line: _this2.currToken[4], | ||
column: _this2.currToken[3] + (index - 1) | ||
line: _this.currToken[4], | ||
column: _this.currToken[5] | ||
} | ||
}, | ||
sourceIndex: _this2.currToken[6] + indices[i] | ||
sourceIndex: startingToken[4] | ||
}); | ||
} else if (~hasId.indexOf(ind)) { | ||
node = new _selectorsId2['default']({ | ||
value: value.slice(1), | ||
source: { | ||
start: { | ||
line: _this2.currToken[2], | ||
column: _this2.currToken[3] + ind | ||
}, | ||
end: { | ||
line: _this2.currToken[4], | ||
column: _this2.currToken[3] + (index - 1) | ||
} | ||
}, | ||
sourceIndex: _this2.currToken[6] + indices[i] | ||
}); | ||
} else { | ||
node = new _selectorsTag2['default']({ | ||
value: value, | ||
source: { | ||
start: { | ||
line: _this2.currToken[2], | ||
column: _this2.currToken[3] + ind | ||
}, | ||
end: { | ||
line: _this2.currToken[4], | ||
column: _this2.currToken[3] + (index - 1) | ||
} | ||
}, | ||
sourceIndex: _this2.currToken[6] + indices[i] | ||
}); | ||
_this.newNode(pseudo); | ||
if (length > 1 && _this.nextToken && _this.nextToken[0] === '(') { | ||
_this.error('Misplaced parenthesis.'); | ||
} | ||
}); | ||
})(); | ||
} else { | ||
this.error('Unexpected "' + this.currToken[0] + '" found.'); | ||
} | ||
}; | ||
Parser.prototype.space = function space() { | ||
var token = this.currToken; | ||
// Handle space before and after the selector | ||
if (this.position === 0 || this.prevToken[0] === ',' || this.prevToken[0] === '(') { | ||
this.spaces = token[1]; | ||
this.position++; | ||
} else if (this.position === this.tokens.length - 1 || this.nextToken[0] === ',' || this.nextToken[0] === ')') { | ||
this.current.last.spaces.after = token[1]; | ||
this.position++; | ||
} else { | ||
this.combinator(); | ||
} | ||
}; | ||
Parser.prototype.string = function string() { | ||
var token = this.currToken; | ||
this.newNode(new _string2.default({ | ||
value: this.currToken[1], | ||
source: { | ||
start: { | ||
line: token[2], | ||
column: token[3] | ||
}, | ||
end: { | ||
line: token[4], | ||
column: token[5] | ||
} | ||
_this2.newNode(node, namespace); | ||
}); | ||
}, | ||
sourceIndex: token[6] | ||
})); | ||
this.position++; | ||
}; | ||
Parser.prototype.universal = function universal(namespace) { | ||
var nextToken = this.nextToken; | ||
if (nextToken && nextToken[1] === '|') { | ||
this.position++; | ||
return this.namespace(); | ||
} | ||
}, { | ||
key: 'word', | ||
value: function word(namespace) { | ||
var nextToken = this.nextToken; | ||
if (nextToken && nextToken[1] === '|') { | ||
this.position++; | ||
return this.namespace(); | ||
this.newNode(new _universal2.default({ | ||
value: this.currToken[1], | ||
source: { | ||
start: { | ||
line: this.currToken[2], | ||
column: this.currToken[3] | ||
}, | ||
end: { | ||
line: this.currToken[2], | ||
column: this.currToken[3] | ||
} | ||
}, | ||
sourceIndex: this.currToken[4] | ||
}), namespace); | ||
this.position++; | ||
}; | ||
Parser.prototype.splitWord = function splitWord(namespace, firstCallback) { | ||
var _this2 = this; | ||
var nextToken = this.nextToken; | ||
var word = this.currToken[1]; | ||
while (nextToken && nextToken[0] === 'word') { | ||
this.position++; | ||
var current = this.currToken[1]; | ||
word += current; | ||
if (current.lastIndexOf('\\') === current.length - 1) { | ||
var next = this.nextToken; | ||
if (next && next[0] === 'space') { | ||
word += next[1]; | ||
this.position++; | ||
} | ||
} | ||
return this.splitWord(namespace); | ||
nextToken = this.nextToken; | ||
} | ||
}, { | ||
key: 'loop', | ||
value: function loop() { | ||
while (this.position < this.tokens.length) { | ||
this.parse(); | ||
var hasClass = (0, _indexesOf2.default)(word, '.'); | ||
var hasId = (0, _indexesOf2.default)(word, '#'); | ||
var indices = (0, _sortAscending2.default)((0, _uniq2.default)((0, _flatten2.default)([[0], hasClass, hasId]))); | ||
indices.forEach(function (ind, i) { | ||
var index = indices[i + 1] || word.length; | ||
var value = word.slice(ind, index); | ||
if (i === 0 && firstCallback) { | ||
return firstCallback.call(_this2, value, indices.length); | ||
} | ||
return this.root; | ||
} | ||
}, { | ||
key: 'parse', | ||
value: function parse() { | ||
switch (this.currToken[0]) { | ||
case 'space': | ||
this.space(); | ||
break; | ||
case 'comment': | ||
this.comment(); | ||
break; | ||
case '(': | ||
this.parentheses(); | ||
break; | ||
case '[': | ||
this.attribute(); | ||
break; | ||
case 'at-word': | ||
case 'word': | ||
this.word(); | ||
break; | ||
case ':': | ||
this.pseudo(); | ||
break; | ||
case ',': | ||
this.comma(); | ||
break; | ||
case '*': | ||
this.universal(); | ||
break; | ||
case 'combinator': | ||
this.combinator(); | ||
break; | ||
case 'string': | ||
this.string(); | ||
break; | ||
var node = undefined; | ||
if (~hasClass.indexOf(ind)) { | ||
node = new _className2.default({ | ||
value: value.slice(1), | ||
source: { | ||
start: { | ||
line: _this2.currToken[2], | ||
column: _this2.currToken[3] + ind | ||
}, | ||
end: { | ||
line: _this2.currToken[4], | ||
column: _this2.currToken[3] + (index - 1) | ||
} | ||
}, | ||
sourceIndex: _this2.currToken[6] + indices[i] | ||
}); | ||
} else if (~hasId.indexOf(ind)) { | ||
node = new _id2.default({ | ||
value: value.slice(1), | ||
source: { | ||
start: { | ||
line: _this2.currToken[2], | ||
column: _this2.currToken[3] + ind | ||
}, | ||
end: { | ||
line: _this2.currToken[4], | ||
column: _this2.currToken[3] + (index - 1) | ||
} | ||
}, | ||
sourceIndex: _this2.currToken[6] + indices[i] | ||
}); | ||
} else { | ||
node = new _tag2.default({ | ||
value: value, | ||
source: { | ||
start: { | ||
line: _this2.currToken[2], | ||
column: _this2.currToken[3] + ind | ||
}, | ||
end: { | ||
line: _this2.currToken[4], | ||
column: _this2.currToken[3] + (index - 1) | ||
} | ||
}, | ||
sourceIndex: _this2.currToken[6] + indices[i] | ||
}); | ||
} | ||
_this2.newNode(node, namespace); | ||
}); | ||
this.position++; | ||
}; | ||
Parser.prototype.word = function word(namespace) { | ||
var nextToken = this.nextToken; | ||
if (nextToken && nextToken[1] === '|') { | ||
this.position++; | ||
return this.namespace(); | ||
} | ||
return this.splitWord(namespace); | ||
}; | ||
/** | ||
* Helpers | ||
*/ | ||
Parser.prototype.loop = function loop() { | ||
while (this.position < this.tokens.length) { | ||
this.parse(); | ||
} | ||
return this.root; | ||
}; | ||
}, { | ||
key: 'newNode', | ||
value: function newNode(node, namespace) { | ||
if (namespace) { | ||
node.namespace = namespace; | ||
} | ||
if (this.spaces) { | ||
node.spaces.before = this.spaces; | ||
this.spaces = ''; | ||
} | ||
return this.current.append(node); | ||
Parser.prototype.parse = function parse() { | ||
switch (this.currToken[0]) { | ||
case 'space': | ||
this.space(); | ||
break; | ||
case 'comment': | ||
this.comment(); | ||
break; | ||
case '(': | ||
this.parentheses(); | ||
break; | ||
case '[': | ||
this.attribute(); | ||
break; | ||
case 'at-word': | ||
case 'word': | ||
this.word(); | ||
break; | ||
case ':': | ||
this.pseudo(); | ||
break; | ||
case ',': | ||
this.comma(); | ||
break; | ||
case '*': | ||
this.universal(); | ||
break; | ||
case 'combinator': | ||
this.combinator(); | ||
break; | ||
case 'string': | ||
this.string(); | ||
break; | ||
} | ||
}, { | ||
}; | ||
/** | ||
* Helpers | ||
*/ | ||
Parser.prototype.newNode = function newNode(node, namespace) { | ||
if (namespace) { | ||
node.namespace = namespace; | ||
} | ||
if (this.spaces) { | ||
node.spaces.before = this.spaces; | ||
this.spaces = ''; | ||
} | ||
return this.current.append(node); | ||
}; | ||
_createClass(Parser, [{ | ||
key: 'currToken', | ||
@@ -558,5 +539,5 @@ get: function get() { | ||
return Parser; | ||
})(); | ||
}(); | ||
exports['default'] = Parser; | ||
exports.default = Parser; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
exports.__esModule = true; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _parser = require('./parser'); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
var _parser2 = _interopRequireDefault(_parser); | ||
var _tokenize = require('./tokenize'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var _tokenize2 = _interopRequireDefault(_tokenize); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _selectorsRoot = require('./selectors/root'); | ||
var _selectorsRoot2 = _interopRequireDefault(_selectorsRoot); | ||
var _parser = require('./parser'); | ||
var _parser2 = _interopRequireDefault(_parser); | ||
var Processor = (function () { | ||
var Processor = function () { | ||
function Processor(func) { | ||
@@ -33,16 +23,15 @@ _classCallCheck(this, Processor); | ||
Processor.prototype.process = function process(selectors) { | ||
var input = new _parser2.default({ | ||
css: selectors, | ||
error: function error(e) { | ||
throw new Error(e); | ||
} | ||
}); | ||
this.res = input; | ||
this.func(input); | ||
return this; | ||
}; | ||
_createClass(Processor, [{ | ||
key: 'process', | ||
value: function process(selectors) { | ||
var input = new _parser2['default']({ | ||
css: selectors, | ||
error: function error(e) { | ||
throw new Error(e); | ||
} | ||
}); | ||
this.res = input; | ||
this.func.call(this, input); | ||
return this; | ||
} | ||
}, { | ||
key: 'result', | ||
@@ -55,5 +44,5 @@ get: function get() { | ||
return Processor; | ||
})(); | ||
}(); | ||
exports['default'] = Processor; | ||
exports.default = Processor; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _namespace = require('./namespace'); | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
var _namespace2 = _interopRequireDefault(_namespace); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
var _namespace = require('./namespace'); | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var _namespace2 = _interopRequireDefault(_namespace); | ||
var Attribute = (function (_Namespace) { | ||
var Attribute = function (_Namespace) { | ||
_inherits(Attribute, _Namespace); | ||
@@ -27,32 +23,31 @@ | ||
_get(Object.getPrototypeOf(Attribute.prototype), 'constructor', this).call(this, opts); | ||
this.type = 'attribute'; | ||
this.raw = {}; | ||
var _this = _possibleConstructorReturn(this, _Namespace.call(this, opts)); | ||
_this.type = 'attribute'; | ||
_this.raw = {}; | ||
return _this; | ||
} | ||
_createClass(Attribute, [{ | ||
key: 'toString', | ||
value: function toString() { | ||
var selector = [this.spaces.before, '[', this.ns, this.attribute]; | ||
Attribute.prototype.toString = function toString() { | ||
var selector = [this.spaces.before, '[', this.ns, this.attribute]; | ||
if (this.operator) { | ||
selector.push(this.operator); | ||
} | ||
if (this.value) { | ||
selector.push(this.value); | ||
} | ||
if (this.raw.insensitive) { | ||
selector.push(this.raw.insensitive); | ||
} else if (this.insensitive) { | ||
selector.push(' i'); | ||
} | ||
selector.push(']'); | ||
return selector.concat(this.spaces.after).join(''); | ||
if (this.operator) { | ||
selector.push(this.operator); | ||
} | ||
}]); | ||
if (this.value) { | ||
selector.push(this.value); | ||
} | ||
if (this.raw.insensitive) { | ||
selector.push(this.raw.insensitive); | ||
} else if (this.insensitive) { | ||
selector.push(' i'); | ||
} | ||
selector.push(']'); | ||
return selector.concat(this.spaces.after).join(''); | ||
}; | ||
return Attribute; | ||
})(_namespace2['default']); | ||
}(_namespace2.default); | ||
exports['default'] = Attribute; | ||
exports.default = Attribute; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _namespace = require('./namespace'); | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
var _namespace2 = _interopRequireDefault(_namespace); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
var _namespace = require('./namespace'); | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var _namespace2 = _interopRequireDefault(_namespace); | ||
var ClassName = (function (_Namespace) { | ||
var ClassName = function (_Namespace) { | ||
_inherits(ClassName, _Namespace); | ||
@@ -27,17 +23,16 @@ | ||
_get(Object.getPrototypeOf(ClassName.prototype), 'constructor', this).call(this, opts); | ||
this.type = 'class'; | ||
var _this = _possibleConstructorReturn(this, _Namespace.call(this, opts)); | ||
_this.type = 'class'; | ||
return _this; | ||
} | ||
_createClass(ClassName, [{ | ||
key: 'toString', | ||
value: function toString() { | ||
return [this.spaces.before, this.ns, String('.' + this.value), this.spaces.after].join(''); | ||
} | ||
}]); | ||
ClassName.prototype.toString = function toString() { | ||
return [this.spaces.before, this.ns, String('.' + this.value), this.spaces.after].join(''); | ||
}; | ||
return ClassName; | ||
})(_namespace2['default']); | ||
}(_namespace2.default); | ||
exports['default'] = ClassName; | ||
exports.default = ClassName; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
var _node = require('./node'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _node2 = _interopRequireDefault(_node); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _node = require('./node'); | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
var _node2 = _interopRequireDefault(_node); | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var Combinator = (function (_Node) { | ||
var Combinator = function (_Node) { | ||
_inherits(Combinator, _Node); | ||
@@ -25,10 +23,12 @@ | ||
_get(Object.getPrototypeOf(Combinator.prototype), 'constructor', this).call(this, opts); | ||
this.type = 'combinator'; | ||
var _this = _possibleConstructorReturn(this, _Node.call(this, opts)); | ||
_this.type = 'combinator'; | ||
return _this; | ||
} | ||
return Combinator; | ||
})(_node2['default']); | ||
}(_node2.default); | ||
exports['default'] = Combinator; | ||
exports.default = Combinator; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
var _node = require('./node'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _node2 = _interopRequireDefault(_node); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _node = require('./node'); | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
var _node2 = _interopRequireDefault(_node); | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var Comment = (function (_Node) { | ||
var Comment = function (_Node) { | ||
_inherits(Comment, _Node); | ||
@@ -25,10 +23,12 @@ | ||
_get(Object.getPrototypeOf(Comment.prototype), 'constructor', this).call(this, opts); | ||
this.type = 'comment'; | ||
var _this = _possibleConstructorReturn(this, _Node.call(this, opts)); | ||
_this.type = 'comment'; | ||
return _this; | ||
} | ||
return Comment; | ||
})(_node2['default']); | ||
}(_node2.default); | ||
exports['default'] = Comment; | ||
exports.default = Comment; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
exports.__esModule = true; | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
var _node = require('./node'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _node2 = _interopRequireDefault(_node); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _node = require('./node'); | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
var _node2 = _interopRequireDefault(_node); | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var Container = (function (_Node) { | ||
var Container = function (_Node) { | ||
_inherits(Container, _Node); | ||
@@ -27,310 +25,279 @@ | ||
_get(Object.getPrototypeOf(Container.prototype), 'constructor', this).call(this, opts); | ||
if (!this.nodes) { | ||
this.nodes = []; | ||
var _this = _possibleConstructorReturn(this, _Node.call(this, opts)); | ||
if (!_this.nodes) { | ||
_this.nodes = []; | ||
} | ||
return _this; | ||
} | ||
_createClass(Container, [{ | ||
key: 'append', | ||
value: function append(selector) { | ||
selector.parent = this; | ||
this.nodes.push(selector); | ||
return this; | ||
Container.prototype.append = function append(selector) { | ||
selector.parent = this; | ||
this.nodes.push(selector); | ||
return this; | ||
}; | ||
Container.prototype.prepend = function prepend(selector) { | ||
selector.parent = this; | ||
this.nodes.unshift(selector); | ||
return this; | ||
}; | ||
Container.prototype.at = function at(index) { | ||
return this.nodes[index]; | ||
}; | ||
Container.prototype.index = function index(child) { | ||
if (typeof child === 'number') { | ||
return child; | ||
} | ||
}, { | ||
key: 'prepend', | ||
value: function prepend(selector) { | ||
selector.parent = this; | ||
this.nodes.unshift(selector); | ||
return this; | ||
return this.nodes.indexOf(child); | ||
}; | ||
Container.prototype.remove = function remove(child) { | ||
child = this.index(child); | ||
this.at(child).parent = undefined; | ||
this.nodes.splice(child, 1); | ||
var index = undefined; | ||
for (var id in this.indexes) { | ||
index = this.indexes[id]; | ||
if (index >= child) { | ||
this.indexes[id] = index - 1; | ||
} | ||
} | ||
}, { | ||
key: 'at', | ||
value: function at(index) { | ||
return this.nodes[index]; | ||
return this; | ||
}; | ||
Container.prototype.removeAll = function removeAll() { | ||
for (var _iterator = this.nodes, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref; | ||
if (_isArray) { | ||
if (_i >= _iterator.length) break; | ||
_ref = _iterator[_i++]; | ||
} else { | ||
_i = _iterator.next(); | ||
if (_i.done) break; | ||
_ref = _i.value; | ||
} | ||
var node = _ref; | ||
node.parent = undefined; | ||
} | ||
}, { | ||
key: 'index', | ||
value: function index(child) { | ||
if (typeof child === 'number') { | ||
return child; | ||
this.nodes = []; | ||
return this; | ||
}; | ||
Container.prototype.empty = function empty() { | ||
return this.removeAll(); | ||
}; | ||
Container.prototype.insertAfter = function insertAfter(oldNode, newNode) { | ||
var oldIndex = this.index(oldNode); | ||
this.nodes.splice(oldIndex + 1, 0, newNode); | ||
var index = undefined; | ||
for (var id in this.indexes) { | ||
index = this.indexes[id]; | ||
if (oldIndex <= index) { | ||
this.indexes[id] = index + this.nodes.length; | ||
} | ||
return this.nodes.indexOf(child); | ||
} | ||
}, { | ||
key: 'remove', | ||
value: function remove(child) { | ||
child = this.index(child); | ||
this.at(child).parent = undefined; | ||
this.nodes.splice(child, 1); | ||
var index = undefined; | ||
for (var id in this.indexes) { | ||
index = this.indexes[id]; | ||
if (index >= child) { | ||
this.indexes[id] = index - 1; | ||
} | ||
return this; | ||
}; | ||
Container.prototype.insertBefore = function insertBefore(oldNode, newNode) { | ||
var oldIndex = this.index(oldNode); | ||
this.nodes.splice(oldIndex, 0, newNode); | ||
var index = undefined; | ||
for (var id in this.indexes) { | ||
index = this.indexes[id]; | ||
if (oldIndex <= index) { | ||
this.indexes[id] = index + this.nodes.length; | ||
} | ||
} | ||
return this; | ||
return this; | ||
}; | ||
Container.prototype.each = function each(callback) { | ||
if (!this.lastEach) { | ||
this.lastEach = 0; | ||
} | ||
}, { | ||
key: 'removeAll', | ||
value: function removeAll() { | ||
var _iteratorNormalCompletion = true; | ||
var _didIteratorError = false; | ||
var _iteratorError = undefined; | ||
if (!this.indexes) { | ||
this.indexes = {}; | ||
} | ||
try { | ||
for (var _iterator = this.nodes[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) { | ||
var node = _step.value; | ||
node.parent = undefined; | ||
} | ||
} catch (err) { | ||
_didIteratorError = true; | ||
_iteratorError = err; | ||
} finally { | ||
try { | ||
if (!_iteratorNormalCompletion && _iterator['return']) { | ||
_iterator['return'](); | ||
} | ||
} finally { | ||
if (_didIteratorError) { | ||
throw _iteratorError; | ||
} | ||
} | ||
this.lastEach++; | ||
var id = this.lastEach; | ||
this.indexes[id] = 0; | ||
if (!this.length) { | ||
return undefined; | ||
} | ||
var index = undefined, | ||
result = undefined; | ||
while (this.indexes[id] < this.length) { | ||
index = this.indexes[id]; | ||
result = callback(this.at(index), index); | ||
if (result === false) { | ||
break; | ||
} | ||
this.nodes = []; | ||
return this; | ||
this.indexes[id] += 1; | ||
} | ||
}, { | ||
key: 'empty', | ||
value: function empty() { | ||
return this.removeAll(); | ||
delete this.indexes[id]; | ||
if (result === false) { | ||
return false; | ||
} | ||
}, { | ||
key: 'insertAfter', | ||
value: function insertAfter(oldNode, newNode) { | ||
var oldIndex = this.index(oldNode); | ||
this.nodes.splice(oldIndex + 1, 0, newNode); | ||
}; | ||
var index = undefined; | ||
for (var id in this.indexes) { | ||
index = this.indexes[id]; | ||
if (oldIndex <= index) { | ||
this.indexes[id] = index + this.nodes.length; | ||
} | ||
Container.prototype.eachInside = function eachInside(callback) { | ||
return this.each(function (node, i) { | ||
var result = callback(node, i); | ||
if (result !== false && node.length) { | ||
result = node.eachInside(callback); | ||
} | ||
return this; | ||
} | ||
}, { | ||
key: 'insertBefore', | ||
value: function insertBefore(oldNode, newNode) { | ||
var oldIndex = this.index(oldNode); | ||
this.nodes.splice(oldIndex, 0, newNode); | ||
if (result === false) { | ||
return false; | ||
} | ||
}); | ||
}; | ||
var index = undefined; | ||
for (var id in this.indexes) { | ||
index = this.indexes[id]; | ||
if (oldIndex <= index) { | ||
this.indexes[id] = index + this.nodes.length; | ||
} | ||
Container.prototype.eachAttribute = function eachAttribute(callback) { | ||
var _this2 = this; | ||
return this.eachInside(function (selector) { | ||
if (selector.type === 'attribute') { | ||
return callback.call(_this2, selector); | ||
} | ||
}); | ||
}; | ||
return this; | ||
} | ||
}, { | ||
key: 'each', | ||
value: function each(callback) { | ||
if (!this.lastEach) { | ||
this.lastEach = 0; | ||
Container.prototype.eachClass = function eachClass(callback) { | ||
var _this3 = this; | ||
return this.eachInside(function (selector) { | ||
if (selector.type === 'class') { | ||
return callback.call(_this3, selector); | ||
} | ||
if (!this.indexes) { | ||
this.indexes = {}; | ||
}); | ||
}; | ||
Container.prototype.eachCombinator = function eachCombinator(callback) { | ||
var _this4 = this; | ||
return this.eachInside(function (selector) { | ||
if (selector.type === 'combinator') { | ||
return callback.call(_this4, selector); | ||
} | ||
}); | ||
}; | ||
this.lastEach++; | ||
var id = this.lastEach; | ||
this.indexes[id] = 0; | ||
Container.prototype.eachComment = function eachComment(callback) { | ||
var _this5 = this; | ||
if (!this.length) return undefined; | ||
return this.eachInside(function (selector) { | ||
if (selector.type === 'comment') { | ||
return callback.call(_this5, selector); | ||
} | ||
}); | ||
}; | ||
var index = undefined, | ||
result = undefined; | ||
while (this.indexes[id] < this.length) { | ||
index = this.indexes[id]; | ||
result = callback(this.at(index), index); | ||
if (result === false) { | ||
break; | ||
} | ||
Container.prototype.eachId = function eachId(callback) { | ||
var _this6 = this; | ||
this.indexes[id] += 1; | ||
return this.eachInside(function (selector) { | ||
if (selector.type === 'id') { | ||
return callback.call(_this6, selector); | ||
} | ||
}); | ||
}; | ||
delete this.indexes[id]; | ||
Container.prototype.eachPseudo = function eachPseudo(callback) { | ||
var _this7 = this; | ||
if (result === false) { | ||
return false; | ||
return this.eachInside(function (selector) { | ||
if (selector.type === 'pseudo') { | ||
return callback.call(_this7, selector); | ||
} | ||
} | ||
}, { | ||
key: 'eachInside', | ||
value: function eachInside(callback) { | ||
return this.each(function (node, i) { | ||
var result = callback(node, i); | ||
}); | ||
}; | ||
if (result !== false && node.length) { | ||
result = node.eachInside(callback); | ||
} | ||
Container.prototype.eachTag = function eachTag(callback) { | ||
var _this8 = this; | ||
if (result === false) { | ||
return false; | ||
} | ||
}); | ||
} | ||
}, { | ||
key: 'eachAttribute', | ||
value: function eachAttribute(callback) { | ||
var _this = this; | ||
return this.eachInside(function (selector) { | ||
if (selector.type === 'tag') { | ||
return callback.call(_this8, selector); | ||
} | ||
}); | ||
}; | ||
return this.eachInside(function (selector) { | ||
if (selector.type === 'attribute') { | ||
return callback.call(_this, selector); | ||
} | ||
}); | ||
} | ||
}, { | ||
key: 'eachClass', | ||
value: function eachClass(callback) { | ||
var _this2 = this; | ||
Container.prototype.eachUniversal = function eachUniversal(callback) { | ||
var _this9 = this; | ||
return this.eachInside(function (selector) { | ||
if (selector.type === 'class') { | ||
return callback.call(_this2, selector); | ||
} | ||
}); | ||
} | ||
}, { | ||
key: 'eachCombinator', | ||
value: function eachCombinator(callback) { | ||
var _this3 = this; | ||
return this.eachInside(function (selector) { | ||
if (selector.type === 'universal') { | ||
return callback.call(_this9, selector); | ||
} | ||
}); | ||
}; | ||
return this.eachInside(function (selector) { | ||
if (selector.type === 'combinator') { | ||
return callback.call(_this3, selector); | ||
} | ||
}); | ||
} | ||
}, { | ||
key: 'eachComment', | ||
value: function eachComment(callback) { | ||
var _this4 = this; | ||
Container.prototype.split = function split(callback) { | ||
var _this10 = this; | ||
return this.eachInside(function (selector) { | ||
if (selector.type === 'comment') { | ||
return callback.call(_this4, selector); | ||
} | ||
}); | ||
} | ||
}, { | ||
key: 'eachId', | ||
value: function eachId(callback) { | ||
var _this5 = this; | ||
var current = []; | ||
return this.reduce(function (memo, node, index) { | ||
var split = callback.call(_this10, node); | ||
current.push(node); | ||
if (split) { | ||
memo.push(current); | ||
current = []; | ||
} else if (index === _this10.length - 1) { | ||
memo.push(current); | ||
} | ||
return memo; | ||
}, []); | ||
}; | ||
return this.eachInside(function (selector) { | ||
if (selector.type === 'id') { | ||
return callback.call(_this5, selector); | ||
} | ||
}); | ||
} | ||
}, { | ||
key: 'eachPseudo', | ||
value: function eachPseudo(callback) { | ||
var _this6 = this; | ||
Container.prototype.map = function map(callback) { | ||
return this.nodes.map(callback); | ||
}; | ||
return this.eachInside(function (selector) { | ||
if (selector.type === 'pseudo') { | ||
return callback.call(_this6, selector); | ||
} | ||
}); | ||
} | ||
}, { | ||
key: 'eachTag', | ||
value: function eachTag(callback) { | ||
var _this7 = this; | ||
Container.prototype.reduce = function reduce(callback, memo) { | ||
return this.nodes.reduce(callback, memo); | ||
}; | ||
return this.eachInside(function (selector) { | ||
if (selector.type === 'tag') { | ||
return callback.call(_this7, selector); | ||
} | ||
}); | ||
} | ||
}, { | ||
key: 'eachUniversal', | ||
value: function eachUniversal(callback) { | ||
var _this8 = this; | ||
Container.prototype.every = function every(callback) { | ||
return this.nodes.every(callback); | ||
}; | ||
return this.eachInside(function (selector) { | ||
if (selector.type === 'universal') { | ||
return callback.call(_this8, selector); | ||
} | ||
}); | ||
} | ||
}, { | ||
key: 'split', | ||
value: function split(callback) { | ||
var _this9 = this; | ||
Container.prototype.some = function some(callback) { | ||
return this.nodes.some(callback); | ||
}; | ||
var current = []; | ||
return this.reduce(function (memo, node, index) { | ||
var split = callback.call(_this9, node); | ||
current.push(node); | ||
if (split) { | ||
memo.push(current); | ||
current = []; | ||
} else if (index === _this9.length - 1) { | ||
memo.push(current); | ||
} | ||
return memo; | ||
}, []); | ||
} | ||
}, { | ||
key: 'map', | ||
value: function map(callback) { | ||
return this.nodes.map(callback); | ||
} | ||
}, { | ||
key: 'reduce', | ||
value: function reduce(callback, memo) { | ||
return this.nodes.reduce(callback, memo); | ||
} | ||
}, { | ||
key: 'every', | ||
value: function every(callback) { | ||
return this.nodes.every(callback); | ||
} | ||
}, { | ||
key: 'some', | ||
value: function some(callback) { | ||
return this.nodes.some(callback); | ||
} | ||
}, { | ||
key: 'filter', | ||
value: function filter(callback) { | ||
return this.nodes.filter(callback); | ||
} | ||
}, { | ||
key: 'sort', | ||
value: function sort(callback) { | ||
return this.nodes.sort(callback); | ||
} | ||
}, { | ||
key: 'toString', | ||
value: function toString() { | ||
return this.map(String).join(''); | ||
} | ||
}, { | ||
Container.prototype.filter = function filter(callback) { | ||
return this.nodes.filter(callback); | ||
}; | ||
Container.prototype.sort = function sort(callback) { | ||
return this.nodes.sort(callback); | ||
}; | ||
Container.prototype.toString = function toString() { | ||
return this.map(String).join(''); | ||
}; | ||
_createClass(Container, [{ | ||
key: 'first', | ||
@@ -353,5 +320,5 @@ get: function get() { | ||
return Container; | ||
})(_node2['default']); | ||
}(_node2.default); | ||
exports['default'] = Container; | ||
exports.default = Container; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _namespace = require('./namespace'); | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
var _namespace2 = _interopRequireDefault(_namespace); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
var _namespace = require('./namespace'); | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var _namespace2 = _interopRequireDefault(_namespace); | ||
var ID = (function (_Namespace) { | ||
var ID = function (_Namespace) { | ||
_inherits(ID, _Namespace); | ||
@@ -27,17 +23,16 @@ | ||
_get(Object.getPrototypeOf(ID.prototype), 'constructor', this).call(this, opts); | ||
this.type = 'id'; | ||
var _this = _possibleConstructorReturn(this, _Namespace.call(this, opts)); | ||
_this.type = 'id'; | ||
return _this; | ||
} | ||
_createClass(ID, [{ | ||
key: 'toString', | ||
value: function toString() { | ||
return [this.spaces.before, this.ns, String('#' + this.value), this.spaces.after].join(''); | ||
} | ||
}]); | ||
ID.prototype.toString = function toString() { | ||
return [this.spaces.before, this.ns, String('#' + this.value), this.spaces.after].join(''); | ||
}; | ||
return ID; | ||
})(_namespace2['default']); | ||
}(_namespace2.default); | ||
exports['default'] = ID; | ||
exports.default = ID; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
exports.__esModule = true; | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
var _node = require('./node'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _node2 = _interopRequireDefault(_node); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _node = require('./node'); | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
var _node2 = _interopRequireDefault(_node); | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var Namespace = (function (_Node) { | ||
var Namespace = function (_Node) { | ||
_inherits(Namespace, _Node); | ||
@@ -27,11 +25,10 @@ | ||
_get(Object.getPrototypeOf(Namespace.prototype), 'constructor', this).apply(this, arguments); | ||
return _possibleConstructorReturn(this, _Node.apply(this, arguments)); | ||
} | ||
Namespace.prototype.toString = function toString() { | ||
return [this.spaces.before, this.ns, String(this.value), this.spaces.after].join(''); | ||
}; | ||
_createClass(Namespace, [{ | ||
key: 'toString', | ||
value: function toString() { | ||
return [this.spaces.before, this.ns, String(this.value), this.spaces.after].join(''); | ||
} | ||
}, { | ||
key: 'ns', | ||
@@ -45,6 +42,6 @@ get: function get() { | ||
return Namespace; | ||
})(_node2['default']); | ||
}(_node2.default); | ||
exports['default'] = Namespace; | ||
exports.default = Namespace; | ||
; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol ? "symbol" : typeof obj; }; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
exports.__esModule = true; | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var cloneNode = function cloneNode(obj, parent) { | ||
if (typeof obj !== 'object') { | ||
if ((typeof obj === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object') { | ||
return obj; | ||
@@ -23,3 +21,3 @@ } | ||
var value = obj[i]; | ||
var type = typeof value; | ||
var type = typeof value === 'undefined' ? 'undefined' : _typeof(value); | ||
@@ -42,7 +40,7 @@ if (i === 'parent' && type === 'object') { | ||
var _default = (function () { | ||
function _default() { | ||
var _class = function () { | ||
function _class() { | ||
var opts = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
_classCallCheck(this, _default); | ||
_classCallCheck(this, _class); | ||
@@ -55,54 +53,46 @@ for (var key in opts) { | ||
_createClass(_default, [{ | ||
key: 'removeSelf', | ||
value: function removeSelf() { | ||
if (this.parent) { | ||
this.parent.remove(this); | ||
} | ||
this.parent = undefined; | ||
return this; | ||
_class.prototype.removeSelf = function removeSelf() { | ||
if (this.parent) { | ||
this.parent.remove(this); | ||
} | ||
}, { | ||
key: 'replaceWith', | ||
value: function replaceWith() { | ||
if (this.parent) { | ||
for (var index in arguments) { | ||
this.parent.insertBefore(this, arguments[index]); | ||
} | ||
this.removeSelf(); | ||
this.parent = undefined; | ||
return this; | ||
}; | ||
_class.prototype.replaceWith = function replaceWith() { | ||
if (this.parent) { | ||
for (var index in arguments) { | ||
this.parent.insertBefore(this, arguments[index]); | ||
} | ||
return this; | ||
this.removeSelf(); | ||
} | ||
}, { | ||
key: 'next', | ||
value: function next() { | ||
return this.parent.at(this.parent.index(this) + 1); | ||
} | ||
}, { | ||
key: 'prev', | ||
value: function prev() { | ||
return this.parent.at(this.parent.index(this) - 1); | ||
} | ||
}, { | ||
key: 'clone', | ||
value: function clone() { | ||
var overrides = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
return this; | ||
}; | ||
var cloned = cloneNode(this); | ||
for (var _name in overrides) { | ||
cloned[_name] = overrides[_name]; | ||
} | ||
return cloned; | ||
_class.prototype.next = function next() { | ||
return this.parent.at(this.parent.index(this) + 1); | ||
}; | ||
_class.prototype.prev = function prev() { | ||
return this.parent.at(this.parent.index(this) - 1); | ||
}; | ||
_class.prototype.clone = function clone() { | ||
var overrides = arguments.length <= 0 || arguments[0] === undefined ? {} : arguments[0]; | ||
var cloned = cloneNode(this); | ||
for (var name in overrides) { | ||
cloned[name] = overrides[name]; | ||
} | ||
}, { | ||
key: 'toString', | ||
value: function toString() { | ||
return [this.spaces.before, String(this.value), this.spaces.after].join(''); | ||
} | ||
}]); | ||
return cloned; | ||
}; | ||
return _default; | ||
})(); | ||
_class.prototype.toString = function toString() { | ||
return [this.spaces.before, String(this.value), this.spaces.after].join(''); | ||
}; | ||
exports['default'] = _default; | ||
return _class; | ||
}(); | ||
exports.default = _class; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _container = require('./container'); | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
var _container2 = _interopRequireDefault(_container); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
var _container = require('./container'); | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var _container2 = _interopRequireDefault(_container); | ||
var Pseudo = (function (_Container) { | ||
var Pseudo = function (_Container) { | ||
_inherits(Pseudo, _Container); | ||
@@ -27,18 +23,17 @@ | ||
_get(Object.getPrototypeOf(Pseudo.prototype), 'constructor', this).call(this, opts); | ||
this.type = 'pseudo'; | ||
var _this = _possibleConstructorReturn(this, _Container.call(this, opts)); | ||
_this.type = 'pseudo'; | ||
return _this; | ||
} | ||
_createClass(Pseudo, [{ | ||
key: 'toString', | ||
value: function toString() { | ||
var params = this.length ? '(' + this.map(String).join(',') + ')' : ''; | ||
return [this.spaces.before, String(this.value), params, this.spaces.after].join(''); | ||
} | ||
}]); | ||
Pseudo.prototype.toString = function toString() { | ||
var params = this.length ? '(' + this.map(String).join(',') + ')' : ''; | ||
return [this.spaces.before, String(this.value), params, this.spaces.after].join(''); | ||
}; | ||
return Pseudo; | ||
})(_container2['default']); | ||
}(_container2.default); | ||
exports['default'] = Pseudo; | ||
exports.default = Pseudo; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
var _createClass = (function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ('value' in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; })(); | ||
var _container = require('./container'); | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
var _container2 = _interopRequireDefault(_container); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
var _container = require('./container'); | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var _container2 = _interopRequireDefault(_container); | ||
var Root = (function (_Container) { | ||
var Root = function (_Container) { | ||
_inherits(Root, _Container); | ||
@@ -27,21 +23,20 @@ | ||
_get(Object.getPrototypeOf(Root.prototype), 'constructor', this).call(this, opts); | ||
this.type = 'root'; | ||
var _this = _possibleConstructorReturn(this, _Container.call(this, opts)); | ||
_this.type = 'root'; | ||
return _this; | ||
} | ||
_createClass(Root, [{ | ||
key: 'toString', | ||
value: function toString() { | ||
var str = this.reduce(function (memo, selector) { | ||
var str = String(selector); | ||
return str ? memo + str + ',' : ''; | ||
}, '').slice(0, -1); | ||
return this.trailingComma ? str + ',' : str; | ||
} | ||
}]); | ||
Root.prototype.toString = function toString() { | ||
var str = this.reduce(function (memo, selector) { | ||
var sel = String(selector); | ||
return sel ? memo + sel + ',' : ''; | ||
}, '').slice(0, -1); | ||
return this.trailingComma ? str + ',' : str; | ||
}; | ||
return Root; | ||
})(_container2['default']); | ||
}(_container2.default); | ||
exports['default'] = Root; | ||
exports.default = Root; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
var _container = require('./container'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _container2 = _interopRequireDefault(_container); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _container = require('./container'); | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
var _container2 = _interopRequireDefault(_container); | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var Selector = (function (_Container) { | ||
var Selector = function (_Container) { | ||
_inherits(Selector, _Container); | ||
@@ -25,10 +23,12 @@ | ||
_get(Object.getPrototypeOf(Selector.prototype), 'constructor', this).call(this, opts); | ||
this.type = 'selector'; | ||
var _this = _possibleConstructorReturn(this, _Container.call(this, opts)); | ||
_this.type = 'selector'; | ||
return _this; | ||
} | ||
return Selector; | ||
})(_container2['default']); | ||
}(_container2.default); | ||
exports['default'] = Selector; | ||
exports.default = Selector; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
var _node = require('./node'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _node2 = _interopRequireDefault(_node); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _node = require('./node'); | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
var _node2 = _interopRequireDefault(_node); | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var String = (function (_Node) { | ||
var String = function (_Node) { | ||
_inherits(String, _Node); | ||
@@ -25,10 +23,12 @@ | ||
_get(Object.getPrototypeOf(String.prototype), 'constructor', this).call(this, opts); | ||
this.type = 'string'; | ||
var _this = _possibleConstructorReturn(this, _Node.call(this, opts)); | ||
_this.type = 'string'; | ||
return _this; | ||
} | ||
return String; | ||
})(_node2['default']); | ||
}(_node2.default); | ||
exports['default'] = String; | ||
exports.default = String; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
var _namespace = require('./namespace'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _namespace2 = _interopRequireDefault(_namespace); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _namespace = require('./namespace'); | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
var _namespace2 = _interopRequireDefault(_namespace); | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var Tag = (function (_Namespace) { | ||
var Tag = function (_Namespace) { | ||
_inherits(Tag, _Namespace); | ||
@@ -25,10 +23,12 @@ | ||
_get(Object.getPrototypeOf(Tag.prototype), 'constructor', this).call(this, opts); | ||
this.type = 'tag'; | ||
var _this = _possibleConstructorReturn(this, _Namespace.call(this, opts)); | ||
_this.type = 'tag'; | ||
return _this; | ||
} | ||
return Tag; | ||
})(_namespace2['default']); | ||
}(_namespace2.default); | ||
exports['default'] = Tag; | ||
exports.default = Tag; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports.__esModule = true; | ||
var _get = function get(_x, _x2, _x3) { var _again = true; _function: while (_again) { var object = _x, property = _x2, receiver = _x3; desc = parent = getter = undefined; _again = false; if (object === null) object = Function.prototype; var desc = Object.getOwnPropertyDescriptor(object, property); if (desc === undefined) { var parent = Object.getPrototypeOf(object); if (parent === null) { return undefined; } else { _x = parent; _x2 = property; _x3 = receiver; _again = true; continue _function; } } else if ('value' in desc) { return desc.value; } else { var getter = desc.get; if (getter === undefined) { return undefined; } return getter.call(receiver); } } }; | ||
var _namespace = require('./namespace'); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { 'default': obj }; } | ||
var _namespace2 = _interopRequireDefault(_namespace); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } } | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== 'function' && superClass !== null) { throw new TypeError('Super expression must either be null or a function, not ' + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _namespace = require('./namespace'); | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
var _namespace2 = _interopRequireDefault(_namespace); | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var Universal = (function (_Namespace) { | ||
var Universal = function (_Namespace) { | ||
_inherits(Universal, _Namespace); | ||
@@ -25,11 +23,13 @@ | ||
_get(Object.getPrototypeOf(Universal.prototype), 'constructor', this).call(this, opts); | ||
this.type = 'universal'; | ||
this.value = '*'; | ||
var _this = _possibleConstructorReturn(this, _Namespace.call(this, opts)); | ||
_this.type = 'universal'; | ||
_this.value = '*'; | ||
return _this; | ||
} | ||
return Universal; | ||
})(_namespace2['default']); | ||
}(_namespace2.default); | ||
exports['default'] = Universal; | ||
exports.default = Universal; | ||
module.exports = exports['default']; |
@@ -1,8 +0,5 @@ | ||
'use strict'; | ||
"use strict"; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports['default'] = sortAscending; | ||
exports.__esModule = true; | ||
exports.default = sortAscending; | ||
function sortAscending(list) { | ||
@@ -12,5 +9,3 @@ return list.sort(function (a, b) { | ||
}); | ||
} | ||
; | ||
}; | ||
module.exports = exports['default']; |
'use strict'; | ||
Object.defineProperty(exports, '__esModule', { | ||
value: true | ||
}); | ||
exports['default'] = tokenize; | ||
exports.__esModule = true; | ||
exports.default = tokenize; | ||
var singleQuote = "'".charCodeAt(0), | ||
@@ -142,3 +140,5 @@ doubleQuote = '"'.charCodeAt(0), | ||
next = css.indexOf(quote, next + 1); | ||
if (next === -1) unclosed('quote', quote); | ||
if (next === -1) { | ||
unclosed('quote', quote); | ||
} | ||
escapePos = next; | ||
@@ -175,3 +175,3 @@ while (css.charCodeAt(escapePos - 1) === backslash) { | ||
code = css.charCodeAt(next + 1); | ||
if (escape && (code !== slash && code !== space && code !== newline && code !== tab && code !== cr && code !== feed)) { | ||
if (escape && code !== slash && code !== space && code !== newline && code !== tab && code !== cr && code !== feed) { | ||
next += 1; | ||
@@ -186,3 +186,5 @@ } | ||
next = css.indexOf('*/', pos + 2) + 1; | ||
if (next === 0) unclosed('comment', '*/'); | ||
if (next === 0) { | ||
unclosed('comment', '*/'); | ||
} | ||
@@ -227,3 +229,2 @@ content = css.slice(pos, next + 1); | ||
} | ||
module.exports = exports['default']; |
{ | ||
"name": "postcss-selector-parser", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"devDependencies": { | ||
"babel": "^5.4.3", | ||
"babel-tape-runner": "^1.1.0", | ||
"faucet": "0.0.1", | ||
"tape": "^4.0.0" | ||
"ava": "^0.11.0", | ||
"babel-cli": "^6.4.0", | ||
"babel-core": "^6.4.0", | ||
"babel-plugin-add-module-exports": "^0.1.2", | ||
"babel-preset-es2015": "^6.3.13", | ||
"babel-preset-es2015-loose": "^7.0.0", | ||
"babel-preset-stage-0": "^6.3.13", | ||
"coveralls": "^2.11.6", | ||
"del-cli": "^0.1.2", | ||
"eslint": "^1.10.3", | ||
"nyc": "^5.3.0" | ||
}, | ||
@@ -18,8 +25,9 @@ "main": "dist/index.js", | ||
"scripts": { | ||
"prepublish": "babel src --out-dir dist --ignore /__tests__/", | ||
"test-unformatted": "babel-tape-runner \"src/**/__tests__/*.js\"", | ||
"test": "npm run test-unformatted | faucet" | ||
"pretest": "eslint src", | ||
"prepublish": "de dist && BABEL_ENV=publish babel src --out-dir dist --ignore /__tests__/", | ||
"report": "nyc report --reporter=html", | ||
"test": "nyc ava src/__tests__/*.js" | ||
}, | ||
"dependencies": { | ||
"flatten": "0.0.1", | ||
"flatten": "^1.0.2", | ||
"indexes-of": "^1.0.1", | ||
@@ -35,3 +43,11 @@ "uniq": "^1.0.1" | ||
}, | ||
"repository": "postcss/postcss-selector-parser" | ||
"repository": "postcss/postcss-selector-parser", | ||
"ava": { | ||
"require": "babel-core/register" | ||
}, | ||
"nyc": { | ||
"exclude": [ | ||
"**/__tests__" | ||
] | ||
} | ||
} |
79237
11
1390
+ Addedflatten@1.0.3(transitive)
- Removedflatten@0.0.1(transitive)
Updatedflatten@^1.0.2