Skip to content

Commit

Permalink
[BUGFIX beta] add assertion against dynamic {{input type}}
Browse files Browse the repository at this point in the history
Closes #5047
  • Loading branch information
Amiel Martin committed Aug 4, 2014
1 parent 188ec51 commit c3cd6b9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/ember-handlebars/lib/controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,8 @@ export function inputHelper(options) {
inputType = hash.type,
onEvent = hash.on;

Ember.assert('You can only use a string as a `type` parameter, not a variable', types.type === 'STRING' || types.type === undefined);

delete hash.type;
delete hash.on;

Expand Down
21 changes: 21 additions & 0 deletions packages/ember-handlebars/tests/controls/checkbox_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,27 @@ test("It works", function() {
}, /you must use `checked=/);
});

QUnit.module("{{input type='checkbox'}} - prevent dynamic type", {
setup: function() {
checkboxView = EmberView.extend({
controller: controller,
inputType: "checkbox",
template: compile('{{input type=inputType}}')
}).create();
},

teardown: function() {
destroy(checkboxView);
}
});

test("It works", function() {
expectAssertion(function() {
append();
}, /not a variable/);
});


QUnit.module("{{input type='checkbox'}} - static values", {
setup: function() {
controller = {
Expand Down
2 changes: 1 addition & 1 deletion packages/ember-testing/tests/acceptance_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ QUnit.module("ember-testing Acceptance", {
});

App.CommentsView = EmberView.extend({
defaultTemplate: EmberHandlebars.compile("{{input type=text}}")
defaultTemplate: EmberHandlebars.compile('{{input type="text"}}')
});

App.AbortTransitionRoute = EmberRoute.extend({
Expand Down

0 comments on commit c3cd6b9

Please sign in to comment.