Skip to content

Commit

Permalink
fix empty value for new etr
Browse files Browse the repository at this point in the history
  • Loading branch information
tylerturdenpants authored and Turbo87 committed Sep 29, 2019
1 parent 7fd8009 commit 18cbbf9
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 10 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{{#some-component class=(concat foo (some-helper ted (some-dude bar (a b c)))) }}
help
{{/some-component}}
{{some-component class=(concat foo (some-helper ted (some-dude bar (a b c)))) }}
{{deep-component class=(concat foo (nice-helper ted (some-crazy bar (a d (d e f)))))}}
{{some-component
class=(concat foo (some-helper bar))
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
<SomeComponent class={{concat foo (some-helper ted (some-dude bar (a b c)))}}>
help
</SomeComponent>
<SomeComponent class={{concat foo (some-helper ted (some-dude bar (a b c)))}} />
<DeepComponent class={{concat foo (nice-helper ted (some-crazy bar (a d (d e f))))}} />
<SomeComponent class={{concat foo (some-helper bar)}} />
<SomeComponent class={{concat foo (some-helper bar quuz)}} />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,9 @@ module.exports = function(file, _, options) {
if (converted) {
let toAngleBracket = printHbs(converted);
let attrEqualEmptyString = new RegExp(EMPTY_STRING, 'gi');
let dataEqualsNoValue = new RegExp(`(data-\\S+)(="${EMPTY_STRING}")`, 'gi');
let dataAttrBug = new RegExp(`(data-\\S+)(="")`, 'gi');
let dataEqualsNoValue = /(data-\S+)=""/gim;

// Haxx out valueless data-* and args with the empty string
toAngleBracket = toAngleBracket.replace(attrEqualEmptyString, '');
toAngleBracket = toAngleBracket.replace(dataAttrBug, '$1');
toAngleBracket = toAngleBracket.replace(dataEqualsNoValue, '$1');
return toAngleBracket;
}
Expand Down
12 changes: 6 additions & 6 deletions transforms/lib/transform.js
Original file line number Diff line number Diff line change
Expand Up @@ -256,10 +256,12 @@ function transformToAngleBracket(env, file, options) {
}

if (_valueType === 'PathExpression') {
_value = b.mustache(b.path(a.value.original));
_value = b.mustache(b.path(a.value));
} else if (_valueType === 'SubExpression') {
if (a.value.hash.pairs.length > 0) {
_value = b.mustache(a.value.path.original, a.value.params, a.value.hash);
// _value = b.mustache(a.value.path.original, a.value.params, a.value.hash);
a.value.type = 'MustacheStatement';
_value = a.value;
} else {
const params = a.value.params
.map(p => {
Expand Down Expand Up @@ -492,10 +494,8 @@ function transformToAngleBracket(env, file, options) {

ElementNode(node) {
node.attributes.forEach(a => {
if (a.value && a.value.chars === '' && !a.name.startsWith('data-')) {
if (a.value.chars !== _EMPTY_STRING_) {
a.value = b.string(_EMPTY_STRING_);
}
if (a.value && a.value.chars === '' && a.value.chars === _EMPTY_STRING_) {
a.value = b.text(_EMPTY_STRING_);
}
});
},
Expand Down

0 comments on commit 18cbbf9

Please sign in to comment.