You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
2.7 KiB

4 years ago
  1. 'use strict';
  2. exports.__esModule = true;
  3. 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; }; }();
  4. var _container = require('./container');
  5. var _container2 = _interopRequireDefault(_container);
  6. var _types = require('./types');
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  8. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  9. 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; }
  10. 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; }
  11. var Root = function (_Container) {
  12. _inherits(Root, _Container);
  13. function Root(opts) {
  14. _classCallCheck(this, Root);
  15. var _this = _possibleConstructorReturn(this, _Container.call(this, opts));
  16. _this.type = _types.ROOT;
  17. return _this;
  18. }
  19. Root.prototype.toString = function toString() {
  20. var str = this.reduce(function (memo, selector) {
  21. memo.push(String(selector));
  22. return memo;
  23. }, []).join(',');
  24. return this.trailingComma ? str + ',' : str;
  25. };
  26. Root.prototype.error = function error(message, options) {
  27. if (this._error) {
  28. return this._error(message, options);
  29. } else {
  30. return new Error(message);
  31. }
  32. };
  33. _createClass(Root, [{
  34. key: 'errorGenerator',
  35. set: function set(handler) {
  36. this._error = handler;
  37. }
  38. }]);
  39. return Root;
  40. }(_container2.default);
  41. exports.default = Root;
  42. module.exports = exports['default'];