pseudo.js 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. "use strict";
  2. var __extends = (this && this.__extends) || (function () {
  3. var extendStatics = function (d, b) {
  4. extendStatics = Object.setPrototypeOf ||
  5. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  6. function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
  7. return extendStatics(d, b);
  8. };
  9. return function (d, b) {
  10. if (typeof b !== "function" && b !== null)
  11. throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
  12. extendStatics(d, b);
  13. function __() { this.constructor = d; }
  14. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  15. };
  16. })();
  17. var __importDefault = (this && this.__importDefault) || function (mod) {
  18. return (mod && mod.__esModule) ? mod : { "default": mod };
  19. };
  20. Object.defineProperty(exports, "__esModule", { value: true });
  21. var container_1 = __importDefault(require("./container"));
  22. var types_1 = require("./types");
  23. var Pseudo = /** @class */ (function (_super) {
  24. __extends(Pseudo, _super);
  25. function Pseudo(opts) {
  26. var _this = _super.call(this, opts) || this;
  27. _this.type = types_1.PSEUDO;
  28. return _this;
  29. }
  30. Pseudo.prototype._stringify = function (options, depth, max) {
  31. var _this = this;
  32. if (depth >= max) {
  33. throw new Error("Cannot serialize selector: nesting depth exceeds the maximum of ".concat(max, "."));
  34. }
  35. var params = this.length
  36. ? "(" +
  37. this.map(function (child) { return _this._stringifyChild(child, options, depth + 1, max); }).join(",") +
  38. ")"
  39. : "";
  40. return [this.rawSpaceBefore, this.stringifyProperty("value"), params, this.rawSpaceAfter].join("");
  41. };
  42. return Pseudo;
  43. }(container_1.default));
  44. exports.default = Pseudo;
  45. //# sourceMappingURL=pseudo.js.map