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