Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUGFIX beta] update lastValue of AttrNode even when not rerendering #10544

Merged
merged 1 commit into from
Feb 26, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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