Skip to content

Commit 0d4da3d

Browse files
jacobraskBYK
authored andcommittedMar 8, 2017
Handle JSX boolean attributes (#107)
Boolean JSX attributes have a value of `null`, and will not have any gettext strings.
1 parent a11d966 commit 0d4da3d

File tree

3 files changed

+9
-1
lines changed

3 files changed

+9
-1
lines changed
 

‎lib/jsxgettext.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ var walkBase = Object.assign({}, walk.base, {
2626
},
2727

2828
JSXAttribute: function (node, st, c) {
29-
if (node.value.type === 'JSXExpressionContainer') {
29+
if (node.value && node.value.type === 'JSXExpressionContainer') {
3030
c(node.value, st);
3131
}
3232
},

‎test/inputs/react_component.jsx

+4
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ export default React.createClass({
66
<div>
77
{gettext('nested child component')}
88
</div>
9+
<input
10+
type="text"
11+
placeholder={gettext('component with boolean attribute')}
12+
required />
913
</div>
1014
);
1115
},

‎test/outputs/react_component.pot

+4
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,7 @@ msgstr ""
1313
#: inputs/react_component.jsx:7
1414
msgid "nested child component"
1515
msgstr ""
16+
17+
#: inputs/react_component.jsx:11
18+
msgid "component with boolean attribute"
19+
msgstr ""

0 commit comments

Comments
 (0)