From e128e627f0dfcbfbe2cb57c4e1229d2cbfea2607 Mon Sep 17 00:00:00 2001 From: Jarda Snajdr Date: Sat, 22 Dec 2018 10:56:35 +0100 Subject: [PATCH 1/2] Fix parsing double slash comments inside Sass maps --- lib/tokenize.js | 2 +- test/comment.js | 31 +++++++++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/lib/tokenize.js b/lib/tokenize.js index ef21bf3..4493411 100644 --- a/lib/tokenize.js +++ b/lib/tokenize.js @@ -152,7 +152,7 @@ module.exports = function tokenize (input, options) { case closeParen: parentCount--; - isURLArg = !isURLArg && parentCount === 1; + isURLArg = isURLArg && parentCount > 0; tokens.push([')', ')', line, pos - offset, line, next - offset, diff --git a/test/comment.js b/test/comment.js index eb66e93..34b68cb 100644 --- a/test/comment.js +++ b/test/comment.js @@ -107,6 +107,37 @@ describe('Parser → Comment', () => { { type: 'paren', value: ')' } ] }, + { + it: 'should parse double slash comments after nested function inside url function', + test: 'url(var()//comment\n)', + loose: true, + expected: [ + { type: 'func', value: 'url' }, + { type: 'paren', value: '(' }, + { type: 'func', value: 'var' }, + { type: 'paren', value: '(' }, + { type: 'paren', value: ')' }, + { type: 'comment', value: 'comment' }, + { type: 'paren', value: ')' } + ] + }, + { + it: 'should parse double slash comments inside Sass maps', + test: '(a:(b:c)//comment\n)', + loose: true, + expected: [ + { type: 'paren', value: '(' }, + { type: 'word', value: 'a' }, + { type: 'colon', value: ':' }, + { type: 'paren', value: '(' }, + { type: 'word', value: 'b' }, + { type: 'colon', value: ':' }, + { type: 'word', value: 'c' }, + { type: 'paren', value: ')' }, + { type: 'comment', value: 'comment' }, + { type: 'paren', value: ')' } + ] + }, { it: 'should parse only one double slash empty comment', test: '//\n', From 77c67abf2108157fa351f6732f81d752d0f1b988 Mon Sep 17 00:00:00 2001 From: Jarda Snajdr Date: Wed, 2 Jan 2019 10:11:27 +0100 Subject: [PATCH 2/2] Upgrade natives module to 1.1.6 to fix Gulp crash on latest Node --- package-lock.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7b91165..115640d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "postcss-values-parser", - "version": "1.5.1", + "version": "2.0.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -2700,9 +2700,9 @@ } }, "natives": { - "version": "1.1.5", - "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.5.tgz", - "integrity": "sha512-1pJ+02gl2KJgCPFtpZGtuD4lGSJnIZvvFHCQTOeDRMSXjfu2GmYWuhI8NFMA4W2I5NNFRbfy/YCiVt4CgNpP8A==", + "version": "1.1.6", + "resolved": "https://registry.npmjs.org/natives/-/natives-1.1.6.tgz", + "integrity": "sha512-6+TDFewD4yxY14ptjKaS63GVdtKiES1pTPyxn9Jb0rBqPMZ7VcCiooEhPNsr+mqHtMGxa/5c/HhcC4uPEUw/nA==", "dev": true }, "natural-compare": {