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.

98 lines
6.2 KiB

4 years ago
  1. "use strict";
  2. exports.__esModule = true;
  3. exports.default = void 0;
  4. var _node = _interopRequireDefault(require("./node"));
  5. function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
  6. function _inheritsLoose(subClass, superClass) { subClass.prototype = Object.create(superClass.prototype); subClass.prototype.constructor = subClass; subClass.__proto__ = superClass; }
  7. /**
  8. * Represents a CSS declaration.
  9. *
  10. * @extends Node
  11. *
  12. * @example
  13. * const root = postcss.parse('a { color: black }')
  14. * const decl = root.first.first
  15. * decl.type //=> 'decl'
  16. * decl.toString() //=> ' color: black'
  17. */
  18. var Declaration =
  19. /*#__PURE__*/
  20. function (_Node) {
  21. _inheritsLoose(Declaration, _Node);
  22. function Declaration(defaults) {
  23. var _this;
  24. _this = _Node.call(this, defaults) || this;
  25. _this.type = 'decl';
  26. return _this;
  27. }
  28. /**
  29. * @memberof Declaration#
  30. * @member {string} prop The declarations property name.
  31. *
  32. * @example
  33. * const root = postcss.parse('a { color: black }')
  34. * const decl = root.first.first
  35. * decl.prop //=> 'color'
  36. */
  37. /**
  38. * @memberof Declaration#
  39. * @member {string} value The declarations value.
  40. *
  41. * @example
  42. * const root = postcss.parse('a { color: black }')
  43. * const decl = root.first.first
  44. * decl.value //=> 'black'
  45. */
  46. /**
  47. * @memberof Declaration#
  48. * @member {boolean} important `true` if the declaration
  49. * has an !important annotation.
  50. *
  51. * @example
  52. * const root = postcss.parse('a { color: black !important; color: red }')
  53. * root.first.first.important //=> true
  54. * root.first.last.important //=> undefined
  55. */
  56. /**
  57. * @memberof Declaration#
  58. * @member {object} raws Information to generate byte-to-byte equal
  59. * node string as it was in the origin input.
  60. *
  61. * Every parser saves its own properties,
  62. * but the default CSS parser uses:
  63. *
  64. * * `before`: the space symbols before the node. It also stores `*`
  65. * and `_` symbols before the declaration (IE hack).
  66. * * `between`: the symbols between the property and value
  67. * for declarations.
  68. * * `important`: the content of the important statement,
  69. * if it is not just `!important`.
  70. *
  71. * PostCSS cleans declaration from comments and extra spaces,
  72. * but it stores origin content in raws properties.
  73. * As such, if you dont change a declarations value,
  74. * PostCSS will use the raw value with comments.
  75. *
  76. * @example
  77. * const root = postcss.parse('a {\n color:black\n}')
  78. * root.first.first.raws //=> { before: '\n ', between: ':' }
  79. */
  80. return Declaration;
  81. }(_node.default);
  82. var _default = Declaration;
  83. exports.default = _default;
  84. module.exports = exports.default;
  85. //# sourceMappingURL=data:application/json;charset=utf8;base64,eyJ2ZXJzaW9uIjozLCJzb3VyY2VzIjpbImRlY2xhcmF0aW9uLmVzNiJdLCJuYW1lcyI6WyJEZWNsYXJhdGlvbiIsImRlZmF1bHRzIiwidHlwZSIsIk5vZGUiXSwibWFwcGluZ3MiOiI7Ozs7O0FBQUE7Ozs7OztBQUVBOzs7Ozs7Ozs7OztJQVdNQSxXOzs7OztBQUNKLHVCQUFhQyxRQUFiLEVBQXVCO0FBQUE7O0FBQ3JCLDZCQUFNQSxRQUFOO0FBQ0EsVUFBS0MsSUFBTCxHQUFZLE1BQVo7QUFGcUI7QUFHdEI7QUFFRDs7Ozs7Ozs7OztBQVVBOzs7Ozs7Ozs7O0FBVUE7Ozs7Ozs7Ozs7O0FBV0E7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7Ozs7OztFQXJDd0JDLGE7O2VBK0RYSCxXIiwic291cmNlc0NvbnRlbnQiOlsiaW1wb3J0IE5vZGUgZnJvbSAnLi9ub2RlJ1xuXG4vKipcbiAqIFJlcHJlc2VudHMgYSBDU1MgZGVjbGFyYXRpb24uXG4gKlxuICogQGV4dGVuZHMgTm9kZVxuICpcbiAqIEBleGFtcGxlXG4gKiBjb25zdCByb290ID0gcG9zdGNzcy5wYXJzZSgnYSB7IGNvbG9yOiBibGFjayB9JylcbiAqIGNvbnN0IGRlY2wgPSByb290LmZpcnN0LmZpcnN0XG4gKiBkZWNsLnR5cGUgICAgICAg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