From 766508900de9866d147b372b3f8378829527b3cd Mon Sep 17 00:00:00 2001 From: changfeng Date: Mon, 5 Sep 2022 00:24:52 +0800 Subject: [PATCH] fix #167 --- lib/LessParser.js | 16 +++++++++------- lib/nodes/interpolation.js | 8 ++++++-- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/lib/LessParser.js b/lib/LessParser.js index 098cc4e..70bae81 100644 --- a/lib/LessParser.js +++ b/lib/LessParser.js @@ -142,13 +142,15 @@ module.exports = class LessParser extends Parser { this.tokenizer.back(token); } - this.atrule(this.tokenizer.nextToken()); - this.lastNode.mixin = true; - this.lastNode.raws.identifier = identifier; - - if (important) { - this.lastNode.important = true; - this.lastNode.raws.important = important; + if (this.lastNode) { + this.atrule(this.tokenizer.nextToken()); + this.lastNode.mixin = true; + this.lastNode.raws.identifier = identifier; + + if (important) { + this.lastNode.important = true; + this.lastNode.raws.important = important; + } } } diff --git a/lib/nodes/interpolation.js b/lib/nodes/interpolation.js index 1df4b3c..f6f678f 100644 --- a/lib/nodes/interpolation.js +++ b/lib/nodes/interpolation.js @@ -2,11 +2,15 @@ module.exports = { interpolation(token) { - const tokens = [token, this.tokenizer.nextToken()]; + const tokens = [token]; const validTypes = ['word', '}']; + const nextToken = this.tokenizer.nextToken(); + if (newToken) { + tokens.push(newToken); + } // look for @{ but not @[word]{ - if (tokens[0][1].length > 1 || tokens[1][0] !== '{') { + if (tokens[0][1].length > 1 || (newToken && tokens[1][0] !== '{')) { this.tokenizer.back(tokens[1]); return false; }