Initial commit

This commit is contained in:
Patrick Marsceill
2017-03-09 13:16:08 -05:00
commit b7b0d0d7bf
4147 changed files with 401224 additions and 0 deletions

View File

@@ -0,0 +1,54 @@
'use strict';
exports.__esModule = true;
var _namespace = require('./namespace');
var _namespace2 = _interopRequireDefault(_namespace);
var _types = require('./types');
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 _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; }
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 Attribute = function (_Namespace) {
_inherits(Attribute, _Namespace);
function Attribute(opts) {
_classCallCheck(this, Attribute);
var _this = _possibleConstructorReturn(this, _Namespace.call(this, opts));
_this.type = _types.ATTRIBUTE;
_this.raws = {};
return _this;
}
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.raws.insensitive) {
selector.push(this.raws.insensitive);
} else if (this.insensitive) {
selector.push(' i');
}
selector.push(']');
return selector.concat(this.spaces.after).join('');
};
return Attribute;
}(_namespace2.default);
exports.default = Attribute;
module.exports = exports['default'];

View File

@@ -0,0 +1,39 @@
'use strict';
exports.__esModule = true;
var _namespace = require('./namespace');
var _namespace2 = _interopRequireDefault(_namespace);
var _types = require('./types');
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 _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; }
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 ClassName = function (_Namespace) {
_inherits(ClassName, _Namespace);
function ClassName(opts) {
_classCallCheck(this, ClassName);
var _this = _possibleConstructorReturn(this, _Namespace.call(this, opts));
_this.type = _types.CLASS;
return _this;
}
ClassName.prototype.toString = function toString() {
return [this.spaces.before, this.ns, String('.' + this.value), this.spaces.after].join('');
};
return ClassName;
}(_namespace2.default);
exports.default = ClassName;
module.exports = exports['default'];

View File

@@ -0,0 +1,35 @@
'use strict';
exports.__esModule = true;
var _node = require('./node');
var _node2 = _interopRequireDefault(_node);
var _types = require('./types');
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 _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; }
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) {
_inherits(Combinator, _Node);
function Combinator(opts) {
_classCallCheck(this, Combinator);
var _this = _possibleConstructorReturn(this, _Node.call(this, opts));
_this.type = _types.COMBINATOR;
return _this;
}
return Combinator;
}(_node2.default);
exports.default = Combinator;
module.exports = exports['default'];

View File

@@ -0,0 +1,35 @@
'use strict';
exports.__esModule = true;
var _node = require('./node');
var _node2 = _interopRequireDefault(_node);
var _types = require('./types');
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 _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; }
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) {
_inherits(Comment, _Node);
function Comment(opts) {
_classCallCheck(this, Comment);
var _this = _possibleConstructorReturn(this, _Node.call(this, opts));
_this.type = _types.COMMENT;
return _this;
}
return Comment;
}(_node2.default);
exports.default = Comment;
module.exports = exports['default'];

View File

@@ -0,0 +1,338 @@
'use strict';
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 _node = require('./node');
var _node2 = _interopRequireDefault(_node);
var _types = require('./types');
var types = _interopRequireWildcard(_types);
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
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; }
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) {
_inherits(Container, _Node);
function Container(opts) {
_classCallCheck(this, Container);
var _this = _possibleConstructorReturn(this, _Node.call(this, opts));
if (!_this.nodes) {
_this.nodes = [];
}
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;
}
return this.nodes.indexOf(child);
};
Container.prototype.removeChild = function removeChild(child) {
child = this.index(child);
this.at(child).parent = undefined;
this.nodes.splice(child, 1);
var index = void 0;
for (var id in this.indexes) {
index = this.indexes[id];
if (index >= child) {
this.indexes[id] = index - 1;
}
}
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;
}
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 = void 0;
for (var id in this.indexes) {
index = this.indexes[id];
if (oldIndex <= index) {
this.indexes[id] = index + this.nodes.length;
}
}
return this;
};
Container.prototype.insertBefore = function insertBefore(oldNode, newNode) {
var oldIndex = this.index(oldNode);
this.nodes.splice(oldIndex, 0, newNode);
var index = void 0;
for (var id in this.indexes) {
index = this.indexes[id];
if (oldIndex <= index) {
this.indexes[id] = index + this.nodes.length;
}
}
return this;
};
Container.prototype.each = function each(callback) {
if (!this.lastEach) {
this.lastEach = 0;
}
if (!this.indexes) {
this.indexes = {};
}
this.lastEach++;
var id = this.lastEach;
this.indexes[id] = 0;
if (!this.length) {
return undefined;
}
var index = void 0,
result = void 0;
while (this.indexes[id] < this.length) {
index = this.indexes[id];
result = callback(this.at(index), index);
if (result === false) {
break;
}
this.indexes[id] += 1;
}
delete this.indexes[id];
if (result === false) {
return false;
}
};
Container.prototype.walk = function walk(callback) {
return this.each(function (node, i) {
var result = callback(node, i);
if (result !== false && node.length) {
result = node.walk(callback);
}
if (result === false) {
return false;
}
});
};
Container.prototype.walkAttributes = function walkAttributes(callback) {
var _this2 = this;
return this.walk(function (selector) {
if (selector.type === types.ATTRIBUTE) {
return callback.call(_this2, selector);
}
});
};
Container.prototype.walkClasses = function walkClasses(callback) {
var _this3 = this;
return this.walk(function (selector) {
if (selector.type === types.CLASS) {
return callback.call(_this3, selector);
}
});
};
Container.prototype.walkCombinators = function walkCombinators(callback) {
var _this4 = this;
return this.walk(function (selector) {
if (selector.type === types.COMBINATOR) {
return callback.call(_this4, selector);
}
});
};
Container.prototype.walkComments = function walkComments(callback) {
var _this5 = this;
return this.walk(function (selector) {
if (selector.type === types.COMMENT) {
return callback.call(_this5, selector);
}
});
};
Container.prototype.walkIds = function walkIds(callback) {
var _this6 = this;
return this.walk(function (selector) {
if (selector.type === types.ID) {
return callback.call(_this6, selector);
}
});
};
Container.prototype.walkNesting = function walkNesting(callback) {
var _this7 = this;
return this.walk(function (selector) {
if (selector.type === types.NESTING) {
return callback.call(_this7, selector);
}
});
};
Container.prototype.walkPseudos = function walkPseudos(callback) {
var _this8 = this;
return this.walk(function (selector) {
if (selector.type === types.PSEUDO) {
return callback.call(_this8, selector);
}
});
};
Container.prototype.walkTags = function walkTags(callback) {
var _this9 = this;
return this.walk(function (selector) {
if (selector.type === types.TAG) {
return callback.call(_this9, selector);
}
});
};
Container.prototype.walkUniversals = function walkUniversals(callback) {
var _this10 = this;
return this.walk(function (selector) {
if (selector.type === types.UNIVERSAL) {
return callback.call(_this10, selector);
}
});
};
Container.prototype.split = function split(callback) {
var _this11 = this;
var current = [];
return this.reduce(function (memo, node, index) {
var split = callback.call(_this11, node);
current.push(node);
if (split) {
memo.push(current);
current = [];
} else if (index === _this11.length - 1) {
memo.push(current);
}
return memo;
}, []);
};
Container.prototype.map = function map(callback) {
return this.nodes.map(callback);
};
Container.prototype.reduce = function reduce(callback, memo) {
return this.nodes.reduce(callback, memo);
};
Container.prototype.every = function every(callback) {
return this.nodes.every(callback);
};
Container.prototype.some = function some(callback) {
return this.nodes.some(callback);
};
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',
get: function get() {
return this.at(0);
}
}, {
key: 'last',
get: function get() {
return this.at(this.length - 1);
}
}, {
key: 'length',
get: function get() {
return this.nodes.length;
}
}]);
return Container;
}(_node2.default);
exports.default = Container;
module.exports = exports['default'];

View File

@@ -0,0 +1,39 @@
'use strict';
exports.__esModule = true;
var _namespace = require('./namespace');
var _namespace2 = _interopRequireDefault(_namespace);
var _types = require('./types');
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 _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; }
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 ID = function (_Namespace) {
_inherits(ID, _Namespace);
function ID(opts) {
_classCallCheck(this, ID);
var _this = _possibleConstructorReturn(this, _Namespace.call(this, opts));
_this.type = _types.ID;
return _this;
}
ID.prototype.toString = function toString() {
return [this.spaces.before, this.ns, String('#' + this.value), this.spaces.after].join('');
};
return ID;
}(_namespace2.default);
exports.default = ID;
module.exports = exports['default'];

View File

@@ -0,0 +1,45 @@
'use strict';
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 _node = require('./node');
var _node2 = _interopRequireDefault(_node);
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 _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; }
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) {
_inherits(Namespace, _Node);
function Namespace() {
_classCallCheck(this, Namespace);
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: 'ns',
get: function get() {
var n = this.namespace;
return n ? (typeof n === 'string' ? n : '') + '|' : '';
}
}]);
return Namespace;
}(_node2.default);
exports.default = Namespace;
;
module.exports = exports['default'];

View File

@@ -0,0 +1,36 @@
'use strict';
exports.__esModule = true;
var _node = require('./node');
var _node2 = _interopRequireDefault(_node);
var _types = require('./types');
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 _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; }
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 Nesting = function (_Node) {
_inherits(Nesting, _Node);
function Nesting(opts) {
_classCallCheck(this, Nesting);
var _this = _possibleConstructorReturn(this, _Node.call(this, opts));
_this.type = _types.NESTING;
_this.value = '&';
return _this;
}
return Nesting;
}(_node2.default);
exports.default = Nesting;
module.exports = exports['default'];

View File

@@ -0,0 +1,102 @@
'use strict';
exports.__esModule = 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 && obj !== Symbol.prototype ? "symbol" : typeof obj; };
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 === 'undefined' ? 'undefined' : _typeof(obj)) !== 'object') {
return obj;
}
var cloned = new obj.constructor();
for (var i in obj) {
if (!obj.hasOwnProperty(i)) {
continue;
}
var value = obj[i];
var type = typeof value === 'undefined' ? 'undefined' : _typeof(value);
if (i === 'parent' && type === 'object') {
if (parent) {
cloned[i] = parent;
}
} else if (value instanceof Array) {
cloned[i] = value.map(function (j) {
return cloneNode(j, cloned);
});
} else {
cloned[i] = cloneNode(value, cloned);
}
}
return cloned;
};
var _class = function () {
function _class() {
var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
_classCallCheck(this, _class);
for (var key in opts) {
this[key] = opts[key];
}
var _opts$spaces = opts.spaces;
_opts$spaces = _opts$spaces === undefined ? {} : _opts$spaces;
var _opts$spaces$before = _opts$spaces.before,
before = _opts$spaces$before === undefined ? '' : _opts$spaces$before,
_opts$spaces$after = _opts$spaces.after,
after = _opts$spaces$after === undefined ? '' : _opts$spaces$after;
this.spaces = { before: before, after: after };
}
_class.prototype.remove = function remove() {
if (this.parent) {
this.parent.removeChild(this);
}
this.parent = undefined;
return this;
};
_class.prototype.replaceWith = function replaceWith() {
if (this.parent) {
for (var index in arguments) {
this.parent.insertBefore(this, arguments[index]);
}
this.remove();
}
return this;
};
_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];
}
return cloned;
};
_class.prototype.toString = function toString() {
return [this.spaces.before, String(this.value), this.spaces.after].join('');
};
return _class;
}();
exports.default = _class;
module.exports = exports['default'];

View File

@@ -0,0 +1,40 @@
'use strict';
exports.__esModule = true;
var _container = require('./container');
var _container2 = _interopRequireDefault(_container);
var _types = require('./types');
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 _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; }
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 Pseudo = function (_Container) {
_inherits(Pseudo, _Container);
function Pseudo(opts) {
_classCallCheck(this, Pseudo);
var _this = _possibleConstructorReturn(this, _Container.call(this, opts));
_this.type = _types.PSEUDO;
return _this;
}
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);
exports.default = Pseudo;
module.exports = exports['default'];

View File

@@ -0,0 +1,43 @@
'use strict';
exports.__esModule = true;
var _container = require('./container');
var _container2 = _interopRequireDefault(_container);
var _types = require('./types');
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 _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; }
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 Root = function (_Container) {
_inherits(Root, _Container);
function Root(opts) {
_classCallCheck(this, Root);
var _this = _possibleConstructorReturn(this, _Container.call(this, opts));
_this.type = _types.ROOT;
return _this;
}
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);
exports.default = Root;
module.exports = exports['default'];

View File

@@ -0,0 +1,35 @@
'use strict';
exports.__esModule = true;
var _container = require('./container');
var _container2 = _interopRequireDefault(_container);
var _types = require('./types');
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 _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; }
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) {
_inherits(Selector, _Container);
function Selector(opts) {
_classCallCheck(this, Selector);
var _this = _possibleConstructorReturn(this, _Container.call(this, opts));
_this.type = _types.SELECTOR;
return _this;
}
return Selector;
}(_container2.default);
exports.default = Selector;
module.exports = exports['default'];

View File

@@ -0,0 +1,35 @@
'use strict';
exports.__esModule = true;
var _node = require('./node');
var _node2 = _interopRequireDefault(_node);
var _types = require('./types');
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 _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; }
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) {
_inherits(String, _Node);
function String(opts) {
_classCallCheck(this, String);
var _this = _possibleConstructorReturn(this, _Node.call(this, opts));
_this.type = _types.STRING;
return _this;
}
return String;
}(_node2.default);
exports.default = String;
module.exports = exports['default'];

View File

@@ -0,0 +1,35 @@
'use strict';
exports.__esModule = true;
var _namespace = require('./namespace');
var _namespace2 = _interopRequireDefault(_namespace);
var _types = require('./types');
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 _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; }
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) {
_inherits(Tag, _Namespace);
function Tag(opts) {
_classCallCheck(this, Tag);
var _this = _possibleConstructorReturn(this, _Namespace.call(this, opts));
_this.type = _types.TAG;
return _this;
}
return Tag;
}(_namespace2.default);
exports.default = Tag;
module.exports = exports['default'];

View File

@@ -0,0 +1,15 @@
'use strict';
exports.__esModule = true;
var TAG = exports.TAG = 'tag';
var STRING = exports.STRING = 'string';
var SELECTOR = exports.SELECTOR = 'selector';
var ROOT = exports.ROOT = 'root';
var PSEUDO = exports.PSEUDO = 'pseudo';
var NESTING = exports.NESTING = 'nesting';
var ID = exports.ID = 'id';
var COMMENT = exports.COMMENT = 'comment';
var COMBINATOR = exports.COMBINATOR = 'combinator';
var CLASS = exports.CLASS = 'class';
var ATTRIBUTE = exports.ATTRIBUTE = 'attribute';
var UNIVERSAL = exports.UNIVERSAL = 'universal';

View File

@@ -0,0 +1,36 @@
'use strict';
exports.__esModule = true;
var _namespace = require('./namespace');
var _namespace2 = _interopRequireDefault(_namespace);
var _types = require('./types');
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 _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; }
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) {
_inherits(Universal, _Namespace);
function Universal(opts) {
_classCallCheck(this, Universal);
var _this = _possibleConstructorReturn(this, _Namespace.call(this, opts));
_this.type = _types.UNIVERSAL;
_this.value = '*';
return _this;
}
return Universal;
}(_namespace2.default);
exports.default = Universal;
module.exports = exports['default'];