From 746be2cac8ad851e0440dd0ce3e9a4c01da43eba Mon Sep 17 00:00:00 2001 From: Julien Collard Date: Wed, 25 Jan 2017 14:12:44 +0100 Subject: [PATCH 1/2] fix the default template instance --- paper-autocomplete-input.html | 54 +++++++++-------------------------- 1 file changed, 14 insertions(+), 40 deletions(-) diff --git a/paper-autocomplete-input.html b/paper-autocomplete-input.html index 3671a06..a3c6be7 100644 --- a/paper-autocomplete-input.html +++ b/paper-autocomplete-input.html @@ -335,16 +335,17 @@ type: Object, readOnly: true, value: function() { - var template = Polymer.dom(this).querySelector('template:not([is=default])') || this.$.defaultTemplate; + var template = Polymer.dom(this).querySelector('template:not(#defaultTemplate)'); + var dataHost = this.dataHost; - if (template) { - if (this.dataHost) { - // set dataHost to the context where template has been defined - template._rootDataHost = this.dataHost._rootDataHost || this.dataHost; - } - - return template; + if (!template) { + template = this.$.defaultTemplate; + dataHost = this; } + + template._rootDataHost = dataHost; + + return template; } }, @@ -373,40 +374,13 @@ var r = RegExp(this.value, 'i'); var filteredItems = this.items.filter(function(item) { - var item_string = that._getItemString(item); + var item_string = that.getItemString(item); return r.test(item_string); }); return filteredItems; }, - /** - * The `_getItemString` is used to get the string to display from an item. - * - * @param {Object} item - * @return {String} - */ - _getItemString: function (item) { - if (!this.autocFields) { - return null; - } - if (!item) { - return null; - } - var item_string = ""; - for (var i = 0; i < this.autocFields.length; i++) { - if (!item[this.autocFields[i]]) { - - continue; - } - item_string += item[this.autocFields[i]]; - if (i < this.autocFields.length - 1 && item[this.autocFields[i + 1]]) { - item_string += " - "; - } - } - return item_string; - }, - /** * The `_onAutocItemsResponse` is used when the autocompleting items request has been responded. * @@ -486,7 +460,7 @@ * The `_onSelectedItemChange` is used when the selected item change. */ _onSelectedItemChange: function (n, o) { - this.value = this._getItemString(n); + this.value = this.getItemString(n); if (!n) { return; } @@ -511,8 +485,8 @@ } var that = this; this.set("items", this.items.sort(function (item1, item2) { - var item1_string = that._getItemString(item1); - var item2_string = that._getItemString(item2); + var item1_string = that.getItemString(item1); + var item2_string = that.getItemString(item2); if (item1_string < item2_string) { return -1; } @@ -578,7 +552,7 @@ * The `cancelTyping` method permit to cancel the current typing action. */ cancelTyping: function () { - this.value = this._getItemString(this.selectedItem); + this.value = this.getItemString(this.selectedItem); this._hideResults = true; this.fire("typing-cancelled", this.value); }, From fc3f26c0c404d140b2faab3673d64fe67075603d Mon Sep 17 00:00:00 2001 From: Julien Collard Date: Wed, 25 Jan 2017 14:14:42 +0100 Subject: [PATCH 2/2] update bower version --- bower.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bower.json b/bower.json index 0b9c12c..0b8e590 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "paper-autocomplete-input", - "version": "1.1.1", + "version": "1.1.2", "authors": [ "Julien Collard (http://neilujd.com)" ],