Urara-Blog/node_modules/.pnpm-store/v3/files/33/7c4db29ea99d09aa22dd25440c4f4ae32d90f3ee255fdea6b70e4822e9836ea1b324f1af9cee33b9ac747b5e9a1239d7a45368779f1175c2ea1c02ee3b0e07
2022-08-14 01:14:53 +08:00

43 lines
1.2 KiB
Text

'use strict';
const types = require('../../tokenizer/types.cjs');
// var( <ident> , <value>? )
function varFn() {
const children = this.createList();
this.skipSC();
// NOTE: Don't check more than a first argument is an ident, rest checks are for lexer
children.push(this.Identifier());
this.skipSC();
if (this.tokenType === types.Comma) {
children.push(this.Operator());
const startIndex = this.tokenIndex;
const value = this.parseCustomProperty
? this.Value(null)
: this.Raw(this.tokenIndex, this.consumeUntilExclamationMarkOrSemicolon, false);
if (value.type === 'Value' && value.children.isEmpty) {
for (let offset = startIndex - this.tokenIndex; offset <= 0; offset++) {
if (this.lookupType(offset) === types.WhiteSpace) {
value.children.appendData({
type: 'WhiteSpace',
loc: null,
value: ' '
});
break;
}
}
}
children.push(value);
}
return children;
}
module.exports = varFn;