Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle shorthands in attributes correctly #33

Merged
merged 15 commits into from Mar 20, 2018
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 4 additions & 2 deletions .flowconfig
Expand Up @@ -4,8 +4,10 @@
[include]

[libs]


./scripts/babel-nodes.js

[lints]

[options]

[strict]
152 changes: 87 additions & 65 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 6 additions & 6 deletions package.json
Expand Up @@ -13,10 +13,10 @@
"babylon": "6.18.0",
"common-prefix": "^1.1.0",
"pug-error": "^1.3.2",
"pug-filters": "^2.1.2",
"pug-lexer": "^3.1.0",
"pug-parser": "^4.0.0",
"pug-strip-comments": "1.0.2"
"pug-filters": "^3.0.0",
"pug-lexer": "^4.0.0",
"pug-parser": "^4.0.1",
"pug-strip-comments": "^1.0.3"
},
"devDependencies": {
"babel-cli": "^6.24.1",
Expand All @@ -25,7 +25,7 @@
"babel-plugin-transform-flow-strip-types": "^6.22.0",
"babel-preset-forbeslindesay": "^2.1.0",
"babel-types": "^6.24.1",
"flow-bin": "^0.65.0",
"flow-bin": "^0.66.0",
"husky": "^0.14.3",
"jest": "^22.1.4",
"lint-staged": "^7.0.0",
Expand Down Expand Up @@ -66,4 +66,4 @@
"type": "git",
"url": "https://github.com/pugjs/babel-plugin-transform-react-pug.git"
}
}
}
25 changes: 25 additions & 0 deletions src/__tests__/__snapshots__/attributes-shorthand.test.js.snap
@@ -0,0 +1,25 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`JavaScript output: transformed source code 1`] = `
"// To prevent warnings in console from react
const test = 10;

module.exports = <div data-first={true} data-second={true} data-positive={true} data-negative={false} data-check={true}><div data-one={true} data-two={true} /></div>;"
`;

exports[`html output: generated html 1`] = `
<div
data-check={true}
data-first={true}
data-negative={false}
data-positive={true}
data-second={true}
>
<div
data-one={true}
data-two={true}
/>
</div>
`;

exports[`static html output: static html 1`] = `"<div data-first=\\"true\\" data-second=\\"true\\" data-positive=\\"true\\" data-negative=\\"false\\" data-check=\\"true\\"><div data-one=\\"true\\" data-two=\\"true\\"></div></div>"`;
13 changes: 13 additions & 0 deletions src/__tests__/attributes-shorthand.input.js
@@ -0,0 +1,13 @@
// To prevent warnings in console from react
const test = 10;

module.exports = pug`
div(
data-first
data-second
data-positive=true
data-negative=false
data-check
)
div(data-one data-two)
`;
3 changes: 3 additions & 0 deletions src/__tests__/attributes-shorthand.test.js
@@ -0,0 +1,3 @@
import testHelper from './test-helper';

testHelper(__dirname + '/attributes-shorthand.input.js');