| Index: polymer_1.2.3/bower_components/iron-selector/iron-selectable.html
|
| diff --git a/polymer_1.0.4/bower_components/iron-selector/iron-selectable.html b/polymer_1.2.3/bower_components/iron-selector/iron-selectable.html
|
| similarity index 72%
|
| copy from polymer_1.0.4/bower_components/iron-selector/iron-selectable.html
|
| copy to polymer_1.2.3/bower_components/iron-selector/iron-selectable.html
|
| index f0506d58d9b5fab5a1701e5c4437f7e10f1b4f91..403a7596363fd007ca49f9303c447320cd6d6a15 100644
|
| --- a/polymer_1.0.4/bower_components/iron-selector/iron-selectable.html
|
| +++ b/polymer_1.2.3/bower_components/iron-selector/iron-selectable.html
|
| @@ -15,14 +15,39 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
| /** @polymerBehavior */
|
| Polymer.IronSelectableBehavior = {
|
|
|
| + /**
|
| + * Fired when iron-selector is activated (selected or deselected).
|
| + * It is fired before the selected items are changed.
|
| + * Cancel the event to abort selection.
|
| + *
|
| + * @event iron-activate
|
| + */
|
| +
|
| + /**
|
| + * Fired when an item is selected
|
| + *
|
| + * @event iron-select
|
| + */
|
| +
|
| + /**
|
| + * Fired when an item is deselected
|
| + *
|
| + * @event iron-deselect
|
| + */
|
| +
|
| + /**
|
| + * Fired when the list of selectable items changes (e.g., items are
|
| + * added or removed). The detail of the event is a list of mutation
|
| + * records that describe what changed.
|
| + *
|
| + * @event iron-items-changed
|
| + */
|
| +
|
| properties: {
|
|
|
| /**
|
| * If you want to use the attribute value of an element for `selected` instead of the index,
|
| * set this to the name of the attribute.
|
| - *
|
| - * @attribute attrForSelected
|
| - * @type {string}
|
| */
|
| attrForSelected: {
|
| type: String,
|
| @@ -31,9 +56,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|
|
| /**
|
| * Gets or sets the selected element. The default is to use the index of the item.
|
| - *
|
| - * @attribute selected
|
| - * @type {string}
|
| */
|
| selected: {
|
| type: String,
|
| @@ -43,8 +65,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
| /**
|
| * Returns the currently selected item.
|
| *
|
| - * @attribute selectedItem
|
| - * @type {Object}
|
| + * @type {?Object}
|
| */
|
| selectedItem: {
|
| type: Object,
|
| @@ -56,10 +77,6 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
| * The event that fires from items when they are selected. Selectable
|
| * will listen for this event from items and update the selection state.
|
| * Set to empty string to listen to no events.
|
| - *
|
| - * @attribute activateEvent
|
| - * @type {string}
|
| - * @default 'tap'
|
| */
|
| activateEvent: {
|
| type: String,
|
| @@ -68,19 +85,13 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
| },
|
|
|
| /**
|
| - * This is a CSS selector sting. If this is set, only items that matches the CSS selector
|
| + * This is a CSS selector string. If this is set, only items that match the CSS selector
|
| * are selectable.
|
| - *
|
| - * @attribute selectable
|
| - * @type {string}
|
| */
|
| selectable: String,
|
|
|
| /**
|
| * The class to set on elements when selected.
|
| - *
|
| - * @attribute selectedClass
|
| - * @type {string}
|
| */
|
| selectedClass: {
|
| type: String,
|
| @@ -89,25 +100,43 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|
|
| /**
|
| * The attribute to set on elements when selected.
|
| - *
|
| - * @attribute selectedAttribute
|
| - * @type {string}
|
| */
|
| selectedAttribute: {
|
| type: String,
|
| value: null
|
| - }
|
| + },
|
|
|
| + /**
|
| + * The list of items from which a selection can be made.
|
| + */
|
| + items: {
|
| + type: Array,
|
| + readOnly: true,
|
| + value: function() {
|
| + return [];
|
| + }
|
| + },
|
| +
|
| + /**
|
| + * The set of excluded elements where the key is the `localName`
|
| + * of the element that will be ignored from the item list.
|
| + *
|
| + * @default {template: 1}
|
| + */
|
| + _excludedLocalNames: {
|
| + type: Object,
|
| + value: function() {
|
| + return {
|
| + 'template': 1
|
| + };
|
| + }
|
| + }
|
| },
|
|
|
| observers: [
|
| '_updateSelected(attrForSelected, selected)'
|
| ],
|
|
|
| - excludedLocalNames: {
|
| - 'template': 1
|
| - },
|
| -
|
| created: function() {
|
| this._bindFilterItem = this._filterItem.bind(this);
|
| this._selection = new Polymer.IronSelection(this._applySelection.bind(this));
|
| @@ -115,31 +144,21 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
|
|
| attached: function() {
|
| this._observer = this._observeItems(this);
|
| - this._contentObserver = this._observeContent(this);
|
| + this._updateItems();
|
| + if (!this._shouldUpdateSelection) {
|
| + this._updateSelected(this.attrForSelected,this.selected)
|
| + }
|
| + this._addListener(this.activateEvent);
|
| },
|
|
|
| detached: function() {
|
| if (this._observer) {
|
| - this._observer.disconnect();
|
| - }
|
| - if (this._contentObserver) {
|
| - this._contentObserver.disconnect();
|
| + Polymer.dom(this).unobserveNodes(this._observer);
|
| }
|
| this._removeListener(this.activateEvent);
|
| },
|
|
|
| /**
|
| - * Returns an array of selectable items.
|
| - *
|
| - * @property items
|
| - * @type Array
|
| - */
|
| - get items() {
|
| - var nodes = Polymer.dom(this).queryDistributedElements(this.selectable || '*');
|
| - return Array.prototype.filter.call(nodes, this._bindFilterItem);
|
| - },
|
| -
|
| - /**
|
| * Returns the index of the given item.
|
| *
|
| * @method indexOf
|
| @@ -181,14 +200,16 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
| this.selected = this._indexToValue(index);
|
| },
|
|
|
| + get _shouldUpdateSelection() {
|
| + return this.selected != null;
|
| + },
|
| +
|
| _addListener: function(eventName) {
|
| this.listen(this, eventName, '_activateHandler');
|
| },
|
|
|
| _removeListener: function(eventName) {
|
| - // There is no unlisten yet...
|
| - // https://github.com/Polymer/polymer/issues/1639
|
| - //this.removeEventListener(eventName, this._bindActivateHandler);
|
| + this.unlisten(this, eventName, '_activateHandler');
|
| },
|
|
|
| _activateEventChanged: function(eventName, old) {
|
| @@ -196,6 +217,12 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
| this._addListener(eventName);
|
| },
|
|
|
| + _updateItems: function() {
|
| + var nodes = Polymer.dom(this).queryDistributedElements(this.selectable || '*');
|
| + nodes = Array.prototype.filter.call(nodes, this._bindFilterItem);
|
| + this._setItems(nodes);
|
| + },
|
| +
|
| _updateSelected: function() {
|
| this._selectSelected(this.selected);
|
| },
|
| @@ -205,7 +232,7 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
| },
|
|
|
| _filterItem: function(node) {
|
| - return !this.excludedLocalNames[node.localName];
|
| + return !this._excludedLocalNames[node.localName];
|
| },
|
|
|
| _valueToItem: function(value) {
|
| @@ -254,34 +281,25 @@ subject to an additional IP rights grant found at http://polymer.github.io/PATEN
|
| this._setSelectedItem(this._selection.get());
|
| },
|
|
|
| - // observe content changes under the given node.
|
| - _observeContent: function(node) {
|
| - var content = node.querySelector('content');
|
| - if (content && content.parentElement === node) {
|
| - return this._observeItems(node.domHost);
|
| - }
|
| - },
|
| -
|
| // observe items change under the given node.
|
| _observeItems: function(node) {
|
| - var observer = new MutationObserver(function() {
|
| - if (this.selected != null) {
|
| + return Polymer.dom(node).observeNodes(function(mutations) {
|
| + // Let other interested parties know about the change so that
|
| + // we don't have to recreate mutation observers everywher.
|
| + this.fire('iron-items-changed', mutations, {
|
| + bubbles: false,
|
| + cancelable: false
|
| + });
|
| +
|
| + this._updateItems();
|
| +
|
| + if (this._shouldUpdateSelection) {
|
| this._updateSelected();
|
| }
|
| - }.bind(this));
|
| - observer.observe(node, {
|
| - childList: true,
|
| - subtree: true
|
| });
|
| - return observer;
|
| },
|
|
|
| _activateHandler: function(e) {
|
| - // TODO: remove this when https://github.com/Polymer/polymer/issues/1639 is fixed so we
|
| - // can just remove the old event listener.
|
| - if (e.type !== this.activateEvent) {
|
| - return;
|
| - }
|
| var t = e.target;
|
| var items = this.items;
|
| while (t && t != this) {
|
|
|