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