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.

97 lines
3.8 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. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  10. function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
  11. 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; }
  12. 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; }
  13. var Namespace = function (_Node) {
  14. _inherits(Namespace, _Node);
  15. function Namespace() {
  16. _classCallCheck(this, Namespace);
  17. return _possibleConstructorReturn(this, _Node.apply(this, arguments));
  18. }
  19. Namespace.prototype.qualifiedName = function qualifiedName(value) {
  20. if (this.namespace) {
  21. return this.namespaceString + '|' + value;
  22. } else {
  23. return value;
  24. }
  25. };
  26. Namespace.prototype.toString = function toString() {
  27. return [this.rawSpaceBefore, this.qualifiedName(this.stringifyProperty("value")), this.rawSpaceAfter].join('');
  28. };
  29. _createClass(Namespace, [{
  30. key: 'namespace',
  31. get: function get() {
  32. return this._namespace;
  33. },
  34. set: function set(namespace) {
  35. if (namespace === true || namespace === "*" || namespace === "&") {
  36. this._namespace = namespace;
  37. if (this.raws) {
  38. delete this.raws.namespace;
  39. }
  40. return;
  41. }
  42. var escaped = (0, _cssesc2.default)(namespace, { isIdentifier: true });
  43. this._namespace = namespace;
  44. if (escaped !== namespace) {
  45. (0, _util.ensureObject)(this, "raws");
  46. this.raws.namespace = escaped;
  47. } else if (this.raws) {
  48. delete this.raws.namespace;
  49. }
  50. }
  51. }, {
  52. key: 'ns',
  53. get: function get() {
  54. return this._namespace;
  55. },
  56. set: function set(namespace) {
  57. this.namespace = namespace;
  58. }
  59. }, {
  60. key: 'namespaceString',
  61. get: function get() {
  62. if (this.namespace) {
  63. var ns = this.stringifyProperty("namespace");
  64. if (ns === true) {
  65. return '';
  66. } else {
  67. return ns;
  68. }
  69. } else {
  70. return '';
  71. }
  72. }
  73. }]);
  74. return Namespace;
  75. }(_node2.default);
  76. exports.default = Namespace;
  77. ;
  78. module.exports = exports['default'];