Permalink
Browse files

Added maxlength to TextSupport; added size to TextField; added rows a…

…nd cols to TextArea
  • Loading branch information...
dgeb committed Feb 28, 2012
1 parent 31f6780 commit 469aa5cb4ebe67e4de39c730ef5a31563f705d73
@@ -20,6 +20,9 @@ Ember.TextArea = Ember.View.extend(Ember.TextSupport,
classNames: ['ember-text-area'],

tagName: "textarea",
attributeBindings: ['rows', 'cols'],
rows: null,
cols: null,

/**
@private
@@ -20,7 +20,7 @@ Ember.TextField = Ember.View.extend(Ember.TextSupport,
classNames: ['ember-text-field'],

tagName: "input",
attributeBindings: ['type', 'value'],
type: "text"

attributeBindings: ['type', 'value', 'size'],
type: "text",
size: null
});
@@ -15,9 +15,10 @@ Ember.TextSupport = Ember.Mixin.create(

value: "",

attributeBindings: ['placeholder', 'disabled'],
attributeBindings: ['placeholder', 'disabled', 'maxlength'],
placeholder: null,
disabled: false,
maxlength: null,

insertNewline: Ember.K,
cancel: Ember.K,
@@ -66,11 +66,50 @@ test("input placeholder is updated when setting placeholder property of view", f
textArea.append();
});

equal(textArea.$().attr('placeholder'), "foo", "renders text field with placeholder");
equal(textArea.$().attr('placeholder'), "foo", "renders text area with placeholder");

Ember.run(function() { set(textArea, 'placeholder', 'bar'); });

equal(textArea.$().attr('placeholder'), "bar", "updates text field after placeholder changes");
equal(textArea.$().attr('placeholder'), "bar", "updates text area after placeholder changes");
});

test("input maxlength is updated when setting maxlength property of view", function() {
Ember.run(function() {
set(textArea, 'maxlength', '300');
textArea.append();
});

equal(textArea.$().attr('maxlength'), "300", "renders text area with maxlength");

Ember.run(function() { set(textArea, 'maxlength', '400'); });

equal(textArea.$().attr('maxlength'), "400", "updates text area after maxlength changes");
});

test("input rows is updated when setting rows property of view", function() {
Ember.run(function() {
set(textArea, 'rows', '3');
textArea.append();
});

equal(textArea.$().attr('rows'), "3", "renders text area with rows");

Ember.run(function() { set(textArea, 'rows', '4'); });

equal(textArea.$().attr('rows'), "4", "updates text area after rows changes");
});

test("input cols is updated when setting cols property of view", function() {
Ember.run(function() {
set(textArea, 'cols', '30');
textArea.append();
});

equal(textArea.$().attr('cols'), "30", "renders text area with cols");

Ember.run(function() { set(textArea, 'cols', '40'); });

equal(textArea.$().attr('cols'), "40", "updates text area after cols changes");
});

test("value binding works properly for inputs that haven't been created", function() {
@@ -73,6 +73,32 @@ test("input placeholder is updated when setting placeholder property of view", f
equal(textField.$().attr('placeholder'), "bar", "updates text field after placeholder changes");
});

test("input maxlength is updated when setting maxlength property of view", function() {
Ember.run(function() {
set(textField, 'maxlength', '30');
textField.append();
});

equal(textField.$().attr('maxlength'), "30", "renders text field with maxlength");

Ember.run(function() { set(textField, 'maxlength', '40'); });

equal(textField.$().attr('maxlength'), "40", "updates text field after maxlength changes");
});

test("input size is updated when setting size property of view", function() {
Ember.run(function() {
set(textField, 'size', '30');
textField.append();
});

equal(textField.$().attr('size'), "30", "renders text field with size");

Ember.run(function() { set(textField, 'size', '40'); });

equal(textField.$().attr('size'), "40", "updates text field after size changes");
});

test("input type is configurable when creating view", function() {
Ember.run(function() {
set(textField, 'type', 'password');

0 comments on commit 469aa5c

Please sign in to comment.