Skip to content

Commit

Permalink
Fix spread attribute (#102)
Browse files Browse the repository at this point in the history
* Upgrade pug-lexer

* Add tests for spread attribute
  • Loading branch information
ezhlobo authored Jun 19, 2019
1 parent 01568b2 commit 1a104ea
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 7 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ module.exports = (
first: true
}}
/>
<div {...object} after=\\"after\\" />
<div before=\\"before\\" {...object} />
<div before=\\"before\\" {...object} after=\\"after\\" />
<div className=\\"mix one two\\" />
<div className={\\"mix \\" + 100} />
<div className={\\"mix \\" + array} />
Expand All @@ -34,6 +37,9 @@ module.exports = (
}
}
/>
<div {...object} after=\\"after\\" className=\\"mix\\" />
<div before=\\"before\\" {...object} className=\\"mix\\" />
<div before=\\"before\\" {...object} after=\\"after\\" className=\\"mix\\" />
</div>
);
"
Expand Down Expand Up @@ -84,6 +90,22 @@ exports[`html output: generated html 1`] = `
}
}
/>
<div
after="after"
first="one-in-object"
second="two-in-object"
/>
<div
before="before"
first="one-in-object"
second="two-in-object"
/>
<div
after="after"
before="before"
first="one-in-object"
second="two-in-object"
/>
<div
className="mix one two"
/>
Expand Down Expand Up @@ -111,7 +133,26 @@ exports[`html output: generated html 1`] = `
<div
className="mix [object Object]"
/>
<div
after="after"
className="mix"
first="one-in-object"
second="two-in-object"
/>
<div
before="before"
className="mix"
first="one-in-object"
second="two-in-object"
/>
<div
after="after"
before="before"
className="mix"
first="one-in-object"
second="two-in-object"
/>
</div>
`;

exports[`static html output: static html 1`] = `"<div><div class=\\"one two\\"></div><div class=\\"one two\\"></div><div class=\\"100\\"></div><div class=\\"arr-one,arr-two\\"></div><div class=\\"[object Object]\\"></div><div class=\\"one,two\\"></div><div class=\\"one two\\"></div><div class=\\"[object Object]\\"></div><div class=\\"mix one two\\"></div><div class=\\"mix 100\\"></div><div class=\\"mix arr-one,arr-two\\"></div><div class=\\"mix [object Object]\\"></div><div class=\\"mix,one,two\\"></div><div class=\\"mix one two\\"></div><div class=\\"mix [object Object]\\"></div></div>"`;
exports[`static html output: static html 1`] = `"<div><div class=\\"one two\\"></div><div class=\\"one two\\"></div><div class=\\"100\\"></div><div class=\\"arr-one,arr-two\\"></div><div class=\\"[object Object]\\"></div><div class=\\"one,two\\"></div><div class=\\"one two\\"></div><div class=\\"[object Object]\\"></div><div first=\\"one-in-object\\" second=\\"two-in-object\\" after=\\"after\\"></div><div before=\\"before\\" first=\\"one-in-object\\" second=\\"two-in-object\\"></div><div before=\\"before\\" first=\\"one-in-object\\" second=\\"two-in-object\\" after=\\"after\\"></div><div class=\\"mix one two\\"></div><div class=\\"mix 100\\"></div><div class=\\"mix arr-one,arr-two\\"></div><div class=\\"mix [object Object]\\"></div><div class=\\"mix,one,two\\"></div><div class=\\"mix one two\\"></div><div class=\\"mix [object Object]\\"></div><div first=\\"one-in-object\\" second=\\"two-in-object\\" after=\\"after\\" class=\\"mix\\"></div><div before=\\"before\\" first=\\"one-in-object\\" second=\\"two-in-object\\" class=\\"mix\\"></div><div before=\\"before\\" first=\\"one-in-object\\" second=\\"two-in-object\\" after=\\"after\\" class=\\"mix\\"></div></div>"`;
6 changes: 6 additions & 0 deletions src/__tests__/attributes-transformation.input.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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")
`;
15 changes: 10 additions & 5 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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"
Expand Down

0 comments on commit 1a104ea

Please sign in to comment.