From 1a104eadf420d10b0d6c3593a69bb8a3f9626142 Mon Sep 17 00:00:00 2001 From: Eugene Zhlobo Date: Wed, 19 Jun 2019 10:19:39 +0300 Subject: [PATCH] Fix spread attribute (#102) * Upgrade pug-lexer * Add tests for spread attribute --- package.json | 2 +- .../attributes-transformation.test.js.snap | 43 ++++++++++++++++++- .../attributes-transformation.input.js | 6 +++ yarn.lock | 15 ++++--- 4 files changed, 59 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index d8a983c..d0703f3 100644 --- a/package.json +++ b/package.json @@ -24,7 +24,7 @@ "he": "^1.2.0", "pug-error": "^1.3.2", "pug-filters": "^3.0.1", - "pug-lexer": "^4.0.0", + "pug-lexer": "^4.1.0", "pug-parser": "^5.0.0", "pug-strip-comments": "^1.0.3" }, diff --git a/src/__tests__/__snapshots__/attributes-transformation.test.js.snap b/src/__tests__/__snapshots__/attributes-transformation.test.js.snap index 248a24a..16e0245 100644 --- a/src/__tests__/__snapshots__/attributes-transformation.test.js.snap +++ b/src/__tests__/__snapshots__/attributes-transformation.test.js.snap @@ -20,6 +20,9 @@ module.exports = ( first: true }} /> +
+
+
@@ -34,6 +37,9 @@ module.exports = ( } } /> +
+
+
); " @@ -84,6 +90,22 @@ exports[`html output: generated html 1`] = ` } } /> +
+
+
@@ -111,7 +133,26 @@ exports[`html output: generated html 1`] = `
+
+
+
`; -exports[`static html output: static html 1`] = `"
"`; +exports[`static html output: static html 1`] = `"
"`; diff --git a/src/__tests__/attributes-transformation.input.js b/src/__tests__/attributes-transformation.input.js index 5c0b9f6..edc6d09 100644 --- a/src/__tests__/attributes-transformation.input.js +++ b/src/__tests__/attributes-transformation.input.js @@ -15,6 +15,9 @@ module.exports = pug` div(className=['one', 'two']) div(className=['one', 'two'].join(' ')) div(className={first: true}) + div(...object after="after") + div(before="before" ...object) + div(before="before" ...object after="after") .mix(className="one two") .mix(className=100) @@ -23,4 +26,7 @@ module.exports = pug` .mix(className=['one', 'two']) .mix(className=['one', 'two'].join(' ')) .mix(className={first: true}) + .mix(...object after="after") + .mix(before="before" ...object) + .mix(before="before" ...object after="after") `; diff --git a/yarn.lock b/yarn.lock index 1436812..123b18a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -4289,6 +4289,11 @@ pug-error@^1.3.2: resolved "https://registry.yarnpkg.com/pug-error/-/pug-error-1.3.2.tgz#53ae7d9d29bb03cf564493a026109f54c47f5f26" integrity sha1-U659nSm7A89WRJOgJhCfVMR/XyY= +pug-error@^1.3.3: + version "1.3.3" + resolved "https://registry.yarnpkg.com/pug-error/-/pug-error-1.3.3.tgz#f342fb008752d58034c185de03602dd9ffe15fa6" + integrity sha512-qE3YhESP2mRAWMFJgKdtT5D7ckThRScXRwkfo+Erqga7dyJdY3ZquspprMCj/9sJ2ijm5hXFWQE/A3l4poMWiQ== + pug-filters@^3.0.1: version "3.1.0" resolved "https://registry.yarnpkg.com/pug-filters/-/pug-filters-3.1.0.tgz#27165555bc04c236e4aa2b0366246dfa021b626e" @@ -4302,14 +4307,14 @@ pug-filters@^3.0.1: resolve "^1.1.6" uglify-js "^2.6.1" -pug-lexer@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/pug-lexer/-/pug-lexer-4.0.0.tgz#210c18457ef2e1760242740c5e647bd794cec278" - integrity sha1-IQwYRX7y4XYCQnQMXmR715TOwng= +pug-lexer@^4.1.0: + version "4.1.0" + resolved "https://registry.yarnpkg.com/pug-lexer/-/pug-lexer-4.1.0.tgz#531cde48c7c0b1fcbbc2b85485c8665e31489cfd" + integrity sha512-i55yzEBtjm0mlplW4LoANq7k3S8gDdfC6+LThGEvsK4FuobcKfDAwt6V4jKPH9RtiE3a2Akfg5UpafZ1OksaPA== dependencies: character-parser "^2.1.1" is-expression "^3.0.0" - pug-error "^1.3.2" + pug-error "^1.3.3" pug-parser@^5.0.0: version "5.0.0"