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.

100 lines
2.9 KiB

2 years ago
  1. "use strict";
  2. exports.__esModule = true;
  3. exports["default"] = void 0;
  4. var _cssesc = _interopRequireDefault(require("cssesc"));
  5. var _util = require("../util");
  6. var _node = _interopRequireDefault(require("./node"));
  7. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
  8. 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); } }
  9. function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
  10. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; _setPrototypeOf(subClass, superClass); }
  11. function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
  12. var Namespace = /*#__PURE__*/function (_Node) {
  13. _inheritsLoose(Namespace, _Node);
  14. function Namespace() {
  15. return _Node.apply(this, arguments) || this;
  16. }
  17. var _proto = Namespace.prototype;
  18. _proto.qualifiedName = function qualifiedName(value) {
  19. if (this.namespace) {
  20. return this.namespaceString + "|" + value;
  21. } else {
  22. return value;
  23. }
  24. };
  25. _proto.valueToString = function valueToString() {
  26. return this.qualifiedName(_Node.prototype.valueToString.call(this));
  27. };
  28. _createClass(Namespace, [{
  29. key: "namespace",
  30. get: function get() {
  31. return this._namespace;
  32. },
  33. set: function set(namespace) {
  34. if (namespace === true || namespace === "*" || namespace === "&") {
  35. this._namespace = namespace;
  36. if (this.raws) {
  37. delete this.raws.namespace;
  38. }
  39. return;
  40. }
  41. var escaped = (0, _cssesc["default"])(namespace, {
  42. isIdentifier: true
  43. });
  44. this._namespace = namespace;
  45. if (escaped !== namespace) {
  46. (0, _util.ensureObject)(this, "raws");
  47. this.raws.namespace = escaped;
  48. } else if (this.raws) {
  49. delete this.raws.namespace;
  50. }
  51. }
  52. }, {
  53. key: "ns",
  54. get: function get() {
  55. return this._namespace;
  56. },
  57. set: function set(namespace) {
  58. this.namespace = namespace;
  59. }
  60. }, {
  61. key: "namespaceString",
  62. get: function get() {
  63. if (this.namespace) {
  64. var ns = this.stringifyProperty("namespace");
  65. if (ns === true) {
  66. return '';
  67. } else {
  68. return ns;
  69. }
  70. } else {
  71. return '';
  72. }
  73. }
  74. }]);
  75. return Namespace;
  76. }(_node["default"]);
  77. exports["default"] = Namespace;
  78. ;
  79. module.exports = exports.default;