Skip to content
This repository has been archived by the owner on Apr 4, 2019. It is now read-only.

Commit

Permalink
Merge pull request #443 from Serabe/fix/emberjs/ember.js/12769
Browse files Browse the repository at this point in the history
[BUGFIX beta] Allow unquoted attributes before the end of a self-closing tag
  • Loading branch information
mmun committed Jan 29, 2016
2 parents 8287799 + 4bba45e commit 9e859d5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/htmlbars-compiler/tests/html-compiler-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ test("Unquoted attribute value with multiple nodes throws an exception", functio
return new Error(
`An unquoted attribute value must be a string or a mustache, ` +
`preceeded by whitespace or a '=' character, and ` +
`followed by whitespace or a '>' character (on line ${line})`
`followed by whitespace, a '>' character or a '/>' (on line ${line})`
);
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,13 +169,13 @@ function assembleAttributeValue(parts, isQuoted, isDynamic, line) {
if (isQuoted) {
return assembleConcatenatedValue(parts);
} else {
if (parts.length === 1) {
if (parts.length === 1 || (parts.length === 2 && parts[1] === '/')) {
return parts[0];
} else {
throw new Error(
`An unquoted attribute value must be a string or a mustache, ` +
`preceeded by whitespace or a '=' character, and ` +
`followed by whitespace or a '>' character (on line ${line})`
`followed by whitespace, a '>' character or a '/>' (on line ${line})`
);
}
}
Expand Down
7 changes: 7 additions & 0 deletions packages/htmlbars-syntax/tests/parser-node-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,13 @@ test("Handlebars embedded in an attribute (unquoted)", function() {
]));
});

test("Handlebars embedded in an attribute of a self-closing tag (unqouted)", function() {
var t = '<input value={{foo}}/>';
astEqual(t, b.program([
b.element("input", [ b.attr("value", b.mustache(b.path('foo'))) ], [], []),
]));
});

test("Handlebars embedded in an attribute (sexprs)", function() {
var t = 'some <div class="{{foo (foo "abc")}}">content</div> done';
astEqual(t, b.program([
Expand Down

0 comments on commit 9e859d5

Please sign in to comment.