className.js 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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 cssesc_1 = __importDefault(require("cssesc"));
  22. var util_1 = require("../util");
  23. var node_1 = __importDefault(require("./node"));
  24. var types_1 = require("./types");
  25. var ClassName = /** @class */ (function (_super) {
  26. __extends(ClassName, _super);
  27. function ClassName(opts) {
  28. var _this = _super.call(this, opts) || this;
  29. _this.type = types_1.CLASS;
  30. _this._constructed = true;
  31. return _this;
  32. }
  33. Object.defineProperty(ClassName.prototype, "value", {
  34. get: function () {
  35. return this._value;
  36. },
  37. set: function (v) {
  38. if (this._constructed) {
  39. var escaped = (0, cssesc_1.default)(v, { isIdentifier: true });
  40. if (escaped !== v) {
  41. (0, util_1.ensureObject)(this, "raws");
  42. this.raws.value = escaped;
  43. }
  44. else if (this.raws) {
  45. delete this.raws.value;
  46. }
  47. }
  48. this._value = v;
  49. },
  50. enumerable: false,
  51. configurable: true
  52. });
  53. ClassName.prototype.valueToString = function () {
  54. return "." + _super.prototype.valueToString.call(this);
  55. };
  56. return ClassName;
  57. }(node_1.default));
  58. exports.default = ClassName;
  59. //# sourceMappingURL=className.js.map