Skip to content

Commit

Permalink
Fixed checkbox deprecation messages
Browse files Browse the repository at this point in the history
  • Loading branch information
wagenet committed Apr 8, 2012
1 parent 7fe58cb commit 04c84ce
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
8 changes: 3 additions & 5 deletions packages/ember-handlebars/lib/controls/checkbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,10 +63,8 @@ Ember.Checkbox = Ember.View.extend({
disabled: false,

title: Ember.computed(function(propName, value){
if (value !== undefined) {
ember_warn("Automatically surrounding Ember.Checkbox inputs with a label by providing a 'title' property is deprecated");
return value;
}
ember_deprecate("Automatically surrounding Ember.Checkbox inputs with a label by providing a 'title' property is deprecated", value === undefined);
return value;
}).property().cacheable(),

defaultTemplate: Ember.computed(function(){
Expand All @@ -78,7 +76,7 @@ Ember.Checkbox = Ember.View.extend({
}).property().cacheable(),

value: Ember.computed(function(propName, value){
ember_warn("Ember.Checkbox's 'value' property has been renamed to 'checked' to match the html element attribute name");
ember_deprecate("Ember.Checkbox's 'value' property has been renamed to 'checked' to match the html element attribute name");
if (value !== undefined) {
return set(this, 'checked', value);
} else {
Expand Down
29 changes: 17 additions & 12 deletions packages/ember-handlebars/tests/controls/checkbox_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,17 +103,22 @@ test("wraps the checkbox in a label if a title attribute is provided", function(
});

test("proxies the checked attribute to value for backwards compatibility", function(){
checkboxView = Ember.Checkbox.create({ title: "I have a title" });
append();

set(checkboxView, 'value', true);
equal(get(checkboxView, 'checked'), true, 'checked is updated when value set');
equal(get(checkboxView, 'value'), true, 'value is updated when value set');

set(checkboxView, 'checked', false);

equal(get(checkboxView, 'checked'), false, 'checked is updated when checked set');
equal(get(checkboxView, 'value'), false, 'value is updated when checked set');

Ember.TESTING_DEPRECATION = true;

try {
checkboxView = Ember.Checkbox.create({ title: "I have a title" });
append();

set(checkboxView, 'value', true);
equal(get(checkboxView, 'checked'), true, 'checked is updated when value set');
equal(get(checkboxView, 'value'), true, 'value is updated when value set');

set(checkboxView, 'checked', false);

equal(get(checkboxView, 'checked'), false, 'checked is updated when checked set');
equal(get(checkboxView, 'value'), false, 'value is updated when checked set');
} finally {
Ember.TESTING_DEPRECATION = false;
}
});

0 comments on commit 04c84ce

Please sign in to comment.