root.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  1. "use strict";
  2. exports.__esModule = true;
  3. exports["default"] = void 0;
  4. var _container = _interopRequireDefault(require("./container"));
  5. var _types = require("./types");
  6. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  7. 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); } }
  8. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  9. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  10. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  11. var Root = /*#__PURE__*/function (_Container) {
  12. _inheritsLoose(Root, _Container);
  13. function Root(opts) {
  14. var _this;
  15. _this = _Container.call(this, opts) || this;
  16. _this.type = _types.ROOT;
  17. return _this;
  18. }
  19. var _proto = Root.prototype;
  20. _proto.toString = function toString() {
  21. var str = this.reduce(function (memo, selector) {
  22. memo.push(String(selector));
  23. return memo;
  24. }, []).join(',');
  25. return this.trailingComma ? str + ',' : str;
  26. };
  27. _proto.error = function error(message, options) {
  28. if (this._error) {
  29. return this._error(message, options);
  30. } else {
  31. return new Error(message);
  32. }
  33. };
  34. _createClass(Root, [{
  35. key: "errorGenerator",
  36. set: function set(handler) {
  37. this._error = handler;
  38. }
  39. }]);
  40. return Root;
  41. }(_container["default"]);
  42. exports["default"] = Root;
  43. module.exports = exports.default;