Skip to content

Commit

Permalink
[BUGFIX beta] update lastValue of AttrNode even when not rerendering
Browse files Browse the repository at this point in the history
Fixes 10541
  • Loading branch information
raytiley committed Feb 26, 2015
1 parent a64481a commit 5f327e8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions packages/ember-htmlbars/tests/helpers/input_test.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,26 @@ QUnit.test("cursor position is not lost when updating content", function() {
equal(input.selectionEnd, 3, 'cursor position was not lost');
});

QUnit.test("input can be updated multiple times", function() {
equal(view.$('input').val(), "hello", "precondition - renders text field with value");

var $input = view.$('input');
var input = $input[0];

run(null, set, controller, 'val', '');
equal(view.$('input').val(), "", "updates first time");

// Simulates setting the input to the same value as it already is which won't cause a rerender
run(function() {
input.value = 'derp';
});
run(null, set, controller, 'val', 'derp');
equal(view.$('input').val(), "derp", "updates second time");

run(null, set, controller, 'val', '');
equal(view.$('input').val(), "", "updates third time");
});


QUnit.module("{{input type='text'}} - static values", {
setup: function() {
Expand Down
1 change: 1 addition & 0 deletions packages/ember-views/lib/attr_nodes/attr_node.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ AttrNode.prototype.render = function render(buffer) {

// If user is typing in a value we don't want to rerender and loose cursor position.
if (this.attrName === 'value' && this._morph.element.value === value) {
this.lastValue = value;
return;
}

Expand Down

0 comments on commit 5f327e8

Please sign in to comment.