var.js 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import { Comma, WhiteSpace } from '../../tokenizer/index.js';
  2. // var( <ident> , <value>? )
  3. export default function() {
  4. const children = this.createList();
  5. this.skipSC();
  6. // NOTE: Don't check more than a first argument is an ident, rest checks are for lexer
  7. children.push(this.Identifier());
  8. this.skipSC();
  9. if (this.tokenType === Comma) {
  10. children.push(this.Operator());
  11. const startIndex = this.tokenIndex;
  12. const value = this.parseCustomProperty
  13. ? this.Value(null)
  14. : this.Raw(this.consumeUntilExclamationMarkOrSemicolon, false);
  15. if (value.type === 'Value' && value.children.isEmpty) {
  16. for (let offset = startIndex - this.tokenIndex; offset <= 0; offset++) {
  17. if (this.lookupType(offset) === WhiteSpace) {
  18. value.children.appendData({
  19. type: 'WhiteSpace',
  20. loc: null,
  21. value: ' '
  22. });
  23. break;
  24. }
  25. }
  26. }
  27. children.push(value);
  28. }
  29. return children;
  30. };