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.

66 lines
2.9 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 _cssesc = require('cssesc');
  5. var _cssesc2 = _interopRequireDefault(_cssesc);
  6. var _util = require('../util');
  7. var _node = require('./node');
  8. var _node2 = _interopRequireDefault(_node);
  9. var _types = require('./types');
  10. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  11. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  12. 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; }
  13. 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; }
  14. var ClassName = function (_Node) {
  15. _inherits(ClassName, _Node);
  16. function ClassName(opts) {
  17. _classCallCheck(this, ClassName);
  18. var _this = _possibleConstructorReturn(this, _Node.call(this, opts));
  19. _this.type = _types.CLASS;
  20. _this._constructed = true;
  21. return _this;
  22. }
  23. ClassName.prototype.toString = function toString() {
  24. return [this.rawSpaceBefore, String('.' + this.stringifyProperty("value")), this.rawSpaceAfter].join('');
  25. };
  26. _createClass(ClassName, [{
  27. key: 'value',
  28. set: function set(v) {
  29. if (this._constructed) {
  30. var escaped = (0, _cssesc2.default)(v, { isIdentifier: true });
  31. if (escaped !== v) {
  32. (0, _util.ensureObject)(this, "raws");
  33. this.raws.value = escaped;
  34. } else if (this.raws) {
  35. delete this.raws.value;
  36. }
  37. }
  38. this._value = v;
  39. },
  40. get: function get() {
  41. return this._value;
  42. }
  43. }]);
  44. return ClassName;
  45. }(_node2.default);
  46. exports.default = ClassName;
  47. module.exports = exports['default'];