diff --git a/src/less/parse.js b/src/less/parse.js index 3a69f78d..b1275d56 100644 --- a/src/less/parse.js +++ b/src/less/parse.js @@ -3180,11 +3180,11 @@ function checkStylesheet(i) { // Check every token: while (i < tokensLength) { if (l = checkSC(i) || - checkAtrule(i) || checkRuleset(i) || - checkMixin(i) || checkDeclaration(i) || - checkDeclDelim(i)) i += l; + checkDeclDelim(i) || + checkAtrule(i) || + checkMixin(i)) i += l; else throwError(i); } @@ -3201,11 +3201,11 @@ function getStylesheet() { while (pos < tokensLength) { if (checkSC(pos)) x = x.concat(getSC()); - else if (checkAtrule(pos)) x.push(getAtrule()); else if (checkRuleset(pos)) x.push(getRuleset()); - else if (checkMixin(pos)) x.push(getMixin()); else if (checkDeclaration(pos)) x.push(getDeclaration()); else if (checkDeclDelim(pos)) x.push(getDeclDelim()); + else if (checkAtrule(pos)) x.push(getAtrule()); + else if (checkMixin(pos)) x.push(getMixin()); else throwError(pos); } diff --git a/test/less/stylesheet/issue104.json b/test/less/stylesheet/issue104.json index 7ce23c60..19cde8ff 100644 --- a/test/less/stylesheet/issue104.json +++ b/test/less/stylesheet/issue104.json @@ -1,133 +1,145 @@ { - "type": "stylesheet", - "content": [ - { - "type": "atrule", - "content": [ - { - "type": "atkeyword", - "content": [ - { - "type": "ident", - "content": "image-url", - "syntax": "less", - "start": { + "type": "stylesheet", + "content": [{ + "type": "declaration", + "content": [{ + "type": "property", + "content": [{ + "type": "variable", + "content": [{ + "type": "ident", + "content": "image-url", + "syntax": "less", + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 10 + } + }], + "syntax": "less", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 10 + } + }], + "syntax": "less", + "start": { "line": 1, - "column": 2 - }, - "end": { + "column": 1 + }, + "end": { "line": 1, "column": 10 - } } - ], - "syntax": "less", - "start": { + }, { + "type": "propertyDelimiter", + "content": ":", + "syntax": "less", + "start": { + "line": 1, + "column": 11 + }, + "end": { + "line": 1, + "column": 11 + } + }, { + "type": "space", + "content": " ", + "syntax": "less", + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 12 + } + }, { + "type": "value", + "content": [{ + "type": "string", + "content": "'../image'", + "syntax": "less", + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 22 + } + }], + "syntax": "less", + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 22 + } + }], + "syntax": "less", + "start": { "line": 1, "column": 1 - }, - "end": { - "line": 1, - "column": 10 - } }, - { - "type": "operator", - "content": ":", - "syntax": "less", - "start": { + "end": { "line": 1, - "column": 11 - }, - "end": { + "column": 22 + } + }, { + "type": "declarationDelimiter", + "content": ";", + "syntax": "less", + "start": { "line": 1, - "column": 11 - } + "column": 23 }, - { - "type": "space", - "content": " ", - "syntax": "less", - "start": { + "end": { "line": 1, - "column": 12 - }, - "end": { + "column": 23 + } + }, { + "type": "space", + "content": "\n", + "syntax": "less", + "start": { "line": 1, - "column": 12 - } + "column": 24 }, - { - "type": "string", - "content": "'../image'", - "syntax": "less", - "start": { - "line": 1, - "column": 13 - }, - "end": { + "end": { "line": 1, - "column": 22 - } + "column": 24 } - ], - "syntax": "less", - "start": { + }, { + "type": "singlelineComment", + "content": " Comment", + "syntax": "less", + "start": { + "line": 2, + "column": 1 + }, + "end": { + "line": 2, + "column": 10 + } + }], + "syntax": "less", + "start": { "line": 1, "column": 1 - }, - "end": { - "line": 1, - "column": 22 - } - }, - { - "type": "declarationDelimiter", - "content": ";", - "syntax": "less", - "start": { - "line": 1, - "column": 23 - }, - "end": { - "line": 1, - "column": 23 - } }, - { - "type": "space", - "content": "\n", - "syntax": "less", - "start": { - "line": 1, - "column": 24 - }, - "end": { - "line": 1, - "column": 24 - } - }, - { - "type": "singlelineComment", - "content": " Comment", - "syntax": "less", - "start": { - "line": 2, - "column": 1 - }, - "end": { + "end": { "line": 2, "column": 10 - } } - ], - "syntax": "less", - "start": { - "line": 1, - "column": 1 - }, - "end": { - "line": 2, - "column": 10 - } -} \ No newline at end of file +} diff --git a/test/less/stylesheet/issue17.test1.json b/test/less/stylesheet/issue17.test1.json new file mode 100644 index 00000000..546b412d --- /dev/null +++ b/test/less/stylesheet/issue17.test1.json @@ -0,0 +1,469 @@ +{ + "type": "stylesheet", + "content": [{ + "type": "declaration", + "content": [{ + "type": "property", + "content": [{ + "type": "variable", + "content": [{ + "type": "ident", + "content": "widthSmall", + "syntax": "less", + "start": { + "line": 1, + "column": 2 + }, + "end": { + "line": 1, + "column": 11 + } + }], + "syntax": "less", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 11 + } + }], + "syntax": "less", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 11 + } + }, { + "type": "propertyDelimiter", + "content": ":", + "syntax": "less", + "start": { + "line": 1, + "column": 12 + }, + "end": { + "line": 1, + "column": 12 + } + }, { + "type": "space", + "content": " ", + "syntax": "less", + "start": { + "line": 1, + "column": 13 + }, + "end": { + "line": 1, + "column": 16 + } + }, { + "type": "value", + "content": [{ + "type": "escapedString", + "content": "\"(max-width: 1300px)\"", + "syntax": "less", + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 38 + } + }], + "syntax": "less", + "start": { + "line": 1, + "column": 17 + }, + "end": { + "line": 1, + "column": 38 + } + }], + "syntax": "less", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 1, + "column": 38 + } + }, { + "type": "declarationDelimiter", + "content": ";", + "syntax": "less", + "start": { + "line": 1, + "column": 39 + }, + "end": { + "line": 1, + "column": 39 + } + }, { + "type": "space", + "content": "\n\n", + "syntax": "less", + "start": { + "line": 1, + "column": 40 + }, + "end": { + "line": 2, + "column": 42 + } + }, { + "type": "ruleset", + "content": [{ + "type": "selector", + "content": [{ + "type": "class", + "content": [{ + "type": "ident", + "content": "Foo", + "syntax": "less", + "start": { + "line": 3, + "column": 2 + }, + "end": { + "line": 3, + "column": 4 + } + }], + "syntax": "less", + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 4 + } + }], + "syntax": "less", + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 3, + "column": 4 + } + }, { + "type": "space", + "content": " ", + "syntax": "less", + "start": { + "line": 3, + "column": 5 + }, + "end": { + "line": 3, + "column": 5 + } + }, { + "type": "block", + "content": [{ + "type": "space", + "content": "\n ", + "syntax": "less", + "start": { + "line": 3, + "column": 7 + }, + "end": { + "line": 4, + "column": 2 + } + }, { + "type": "atrule", + "content": [{ + "type": "atkeyword", + "content": [{ + "type": "ident", + "content": "media", + "syntax": "less", + "start": { + "line": 4, + "column": 4 + }, + "end": { + "line": 4, + "column": 8 + } + }], + "syntax": "less", + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 4, + "column": 8 + } + }, { + "type": "space", + "content": " ", + "syntax": "less", + "start": { + "line": 4, + "column": 9 + }, + "end": { + "line": 4, + "column": 9 + } + }, { + "type": "variable", + "content": [{ + "type": "ident", + "content": "widthSmall", + "syntax": "less", + "start": { + "line": 4, + "column": 11 + }, + "end": { + "line": 4, + "column": 20 + } + }], + "syntax": "less", + "start": { + "line": 4, + "column": 10 + }, + "end": { + "line": 4, + "column": 20 + } + }, { + "type": "space", + "content": " ", + "syntax": "less", + "start": { + "line": 4, + "column": 21 + }, + "end": { + "line": 4, + "column": 21 + } + }, { + "type": "block", + "content": [{ + "type": "space", + "content": "\n ", + "syntax": "less", + "start": { + "line": 4, + "column": 23 + }, + "end": { + "line": 5, + "column": 6 + } + }, { + "type": "declaration", + "content": [{ + "type": "property", + "content": [{ + "type": "ident", + "content": "width", + "syntax": "less", + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 11 + } + }], + "syntax": "less", + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 11 + } + }, { + "type": "propertyDelimiter", + "content": ":", + "syntax": "less", + "start": { + "line": 5, + "column": 12 + }, + "end": { + "line": 5, + "column": 12 + } + }, { + "type": "space", + "content": " ", + "syntax": "less", + "start": { + "line": 5, + "column": 13 + }, + "end": { + "line": 5, + "column": 16 + } + }, { + "type": "value", + "content": [{ + "type": "dimension", + "content": [{ + "type": "number", + "content": "400", + "syntax": "less", + "start": { + "line": 5, + "column": 17 + }, + "end": { + "line": 5, + "column": 19 + } + }, { + "type": "ident", + "content": "px", + "syntax": "less", + "start": { + "line": 5, + "column": 20 + }, + "end": { + "line": 5, + "column": 21 + } + }], + "syntax": "less", + "start": { + "line": 5, + "column": 17 + }, + "end": { + "line": 5, + "column": 21 + } + }], + "syntax": "less", + "start": { + "line": 5, + "column": 17 + }, + "end": { + "line": 5, + "column": 21 + } + }], + "syntax": "less", + "start": { + "line": 5, + "column": 7 + }, + "end": { + "line": 5, + "column": 21 + } + }, { + "type": "declarationDelimiter", + "content": ";", + "syntax": "less", + "start": { + "line": 5, + "column": 22 + }, + "end": { + "line": 5, + "column": 22 + } + }, { + "type": "space", + "content": "\n ", + "syntax": "less", + "start": { + "line": 5, + "column": 23 + }, + "end": { + "line": 6, + "column": 2 + } + }], + "syntax": "less", + "start": { + "line": 4, + "column": 22 + }, + "end": { + "line": 6, + "column": 3 + } + }], + "syntax": "less", + "start": { + "line": 4, + "column": 3 + }, + "end": { + "line": 6, + "column": 3 + } + }, { + "type": "space", + "content": "\n", + "syntax": "less", + "start": { + "line": 6, + "column": 4 + }, + "end": { + "line": 6, + "column": 4 + } + }], + "syntax": "less", + "start": { + "line": 3, + "column": 6 + }, + "end": { + "line": 7, + "column": 1 + } + }], + "syntax": "less", + "start": { + "line": 3, + "column": 1 + }, + "end": { + "line": 7, + "column": 1 + } + }], + "syntax": "less", + "start": { + "line": 1, + "column": 1 + }, + "end": { + "line": 7, + "column": 1 + } +} diff --git a/test/less/stylesheet/issue17.test1.less b/test/less/stylesheet/issue17.test1.less new file mode 100644 index 00000000..6d067982 --- /dev/null +++ b/test/less/stylesheet/issue17.test1.less @@ -0,0 +1,7 @@ +@widthSmall: ~"(max-width: 1300px)"; + +.Foo { + @media @widthSmall { + width: 400px; + } +}