combinator.js 668 B

1234567891011121314151617181920212223
  1. var Node = require("./node");
  2. var Combinator = function (value) {
  3. if (value === ' ') {
  4. this.value = ' ';
  5. this.emptyOrWhitespace = true;
  6. } else {
  7. this.value = value ? value.trim() : "";
  8. this.emptyOrWhitespace = this.value === "";
  9. }
  10. };
  11. Combinator.prototype = new Node();
  12. Combinator.prototype.type = "Combinator";
  13. var _noSpaceCombinators = {
  14. '': true,
  15. ' ': true,
  16. '|': true
  17. };
  18. Combinator.prototype.genCSS = function (context, output) {
  19. var spaceOrEmpty = (context.compress || _noSpaceCombinators[this.value]) ? '' : ' ';
  20. output.add(spaceOrEmpty + this.value + spaceOrEmpty);
  21. };
  22. module.exports = Combinator;