Skip to content

Commit

Permalink
Fix regression after css-tree bump to alpha34
Browse files Browse the repository at this point in the history
  • Loading branch information
lahmatiy committed Oct 7, 2019
1 parent 82ff5a0 commit c736167
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 12 deletions.
16 changes: 10 additions & 6 deletions syntax-extension/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
var tokenize = require('css-tree').tokenize;
var TYPE = tokenize.TYPE;
var CHARCODE = tokenize.CHARCODE;
var NUMBERSIGN = 0x0023; // U+0023 NUMBER SIGN (#)
var DOLLARSIGN = 0x0024; // U+0024 DOLLAR SIGN ($)
var PERCENTAGESIGN = 0x0025; // U+0025 PERCENTAGE SIGN (%)
var COMMERCIALAT = 0x0040; // U+0040 COMMERCIAL AT (@)
var TILDE = 0x007E; // U+007E TILDE (~)

// custom
var PreprocessorExtensionError = function() {
Expand All @@ -27,27 +31,27 @@ module.exports = function extendParser(syntaxConfig) {

case TYPE.Delim:
switch (this.scanner.source.charCodeAt(this.scanner.tokenStart)) {
case CHARCODE.CommercialAt: // less: @@var
case COMMERCIALAT: // less: @@var
if (this.scanner.lookupType(1) === TYPE.Atrule) {
node = this.LessVariableReference();
}
break;

case CHARCODE.Tilde: // less: ~"asd" | ~'asd'
case TILDE: // less: ~"asd" | ~'asd'
node = this.LessEscaping();
break;

case CHARCODE.DollarSign: // sass: $var
case DOLLARSIGN: // sass: $var
node = this.SassVariable();
break;

case CHARCODE.NumberSign: // sass: #{ }
case NUMBERSIGN: // sass: #{ }
if (this.scanner.lookupType(1) === TYPE.LeftCurlyBracket) {
node = this.SassInterpolation(this.scope.Value, this.readSequence);
}
break;

case CHARCODE.PercentSign: // sass: 5 % 4
case PERCENTAGESIGN: // sass: 5 % 4
node = this.Operator();
break;
}
Expand Down
2 changes: 1 addition & 1 deletion syntax-extension/less/LessEscaping.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var tokenize = require('css-tree').tokenize;
var TYPE = tokenize.TYPE;
var STRING = TYPE.String;
var TILDE = tokenize.CHARCODE.Tilde;
var TILDE = 0x007E; // U+007E TILDE (~)

module.exports = {
name: 'LessEscaping',
Expand Down
5 changes: 2 additions & 3 deletions syntax-extension/less/LessVariableReference.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
var tokenize = require('css-tree').tokenize;
var TYPE = tokenize.TYPE;
var DELIM = TYPE.Delim;
var ATRULE = TYPE.Atrule;
var CHARCODE = tokenize.CHARCODE;
var COMMERCIALAT = 0x0040; // U+0040 COMMERCIAL AT (@)

module.exports = {
name: 'LessVariableReference',
Expand All @@ -12,7 +11,7 @@ module.exports = {
parse: function LessVariableReference() {
var start = this.scanner.tokenStart;

if (!this.scanner.isDelim(CHARCODE.CommercialAt)) {
if (!this.scanner.isDelim(COMMERCIALAT)) {
this.error()
}

Expand Down
2 changes: 1 addition & 1 deletion syntax-extension/sass/SassInterpolation.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ var tokenize = require('css-tree').tokenize;
var TYPE = tokenize.TYPE;
var LEFTCURLYBRACKET = TYPE.LeftCurlyBracket;
var RIGHTCURLYBRACKET = TYPE.RightCurlyBracket;
var NUMBERSIGN = tokenize.CHARCODE.NumberSign;
var NUMBERSIGN = 0x0023; // U+0023 NUMBER SIGN (#)

module.exports = {
name: 'SassInterpolation',
Expand Down
2 changes: 1 addition & 1 deletion syntax-extension/sass/SassVariable.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
var tokenize = require('css-tree').tokenize;
var IDENT = tokenize.TYPE.Ident;
var DOLLARSIGN = tokenize.CHARCODE.DollarSign;
var DOLLARSIGN = 0x0024; // U+0024 DOLLAR SIGN ($)

module.exports = {
name: 'SassVariable',
Expand Down

0 comments on commit c736167

Please sign in to comment.