Skip to content
This repository has been archived by the owner on Mar 13, 2018. It is now read-only.

Commit

Permalink
Remove a few hacks from td-item
Browse files Browse the repository at this point in the history
- Remove workarounds for Polymer/polymer#186
- Platform.flush is automatic with asyncMethod
  • Loading branch information
dfreedm committed Oct 16, 2013
1 parent 43c9f69 commit 190083a
Showing 1 changed file with 3 additions and 14 deletions.
17 changes: 3 additions & 14 deletions elements/td-item.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,27 @@
<label>{{item.title}}</label>
<button class="destroy" on-click="destroyAction"></button>
</div>
<input is="td-input" id="edit" class="edit" value="{{title}}" hidden?="{{!editing}}" on-td-input-commit="commitAction" on-td-input-cancel="cancelAction">
<input is="td-input" id="edit" class="edit" value="{{item.title}}" hidden?="{{!editing}}" on-td-input-commit="commitAction" on-td-input-cancel="cancelAction">
</template>
<script>
(function() {
var ENTER_KEY = 13;
var ESC_KEY = 27;
Polymer('td-item', {
editing: false,
editAction: function() {
this.editing = true;
// FIXME: Custom elements extended from <input> don't have
// <input> binding behavior.
// https://github.com/Polymer/polymer/issues/186
this.$.edit.value = this.title = this.item.title;
// schedule focus for the end of microtask, when the input will be visible
Platform.flush();
this.asyncMethod(function() {
this.$.edit.focus();
});
},
commitAction: function() {
// FIXME: Custom elements extended from <input> don't have
// <input> binding behavior.
// https://github.com/Polymer/polymer/issues/186
this.title = this.$.edit.value;
if (this.editing) {
this.editing = false;
this.item.title = this.title.trim();
this.item.title = this.item.title.trim();
if (this.item.title === '') {
this.destroyAction();
}
this.fire('td-item-changed');
this.fire('td-item-changed');
}
},
cancelAction: function() {
Expand Down

0 comments on commit 190083a

Please sign in to comment.