From ce32139e491a9c791624938ed347aa1b5fa4e266 Mon Sep 17 00:00:00 2001 From: frankiefu Date: Mon, 12 Aug 2013 14:30:58 -0700 Subject: [PATCH 01/15] update selectedItem after polymer-selection has done processing the item --- polymer-selector/polymer-selector.html | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/polymer-selector/polymer-selector.html b/polymer-selector/polymer-selector.html index f0e2d85..61d90e6 100644 --- a/polymer-selector/polymer-selector.html +++ b/polymer-selector/polymer-selector.html @@ -226,9 +226,11 @@ valueToSelection: function(value) { var item = (value === null || value === undefined) ? null : this.items[this.valueToIndex(value)]; - this.selectedItem = item; this.$.selection.select(item); }, + updateSelectedItem: function() { + this.selectedItem = this.selection; + }, selectedItemChanged: function() { if (this.selectedItem) { var t = this.selectedItem.templateInstance; @@ -252,6 +254,7 @@ }, // events fired from object selectionSelect: function(e, detail) { + this.updateSelectedItem(); if (detail.item) { this.applySelection(detail.item, detail.isSelected) } From 0471fe36314bab4639ee812817e37f1401e2d74a Mon Sep 17 00:00:00 2001 From: frankiefu Date: Mon, 12 Aug 2013 14:31:19 -0700 Subject: [PATCH 02/15] add more tests for polymer-selector --- test/html/polymer-selector-basic.html | 29 ++++++++++++++++++++++++++- test/html/polymer-selector-multi.html | 24 ++++++++++++++++++---- 2 files changed, 48 insertions(+), 5 deletions(-) diff --git a/test/html/polymer-selector-basic.html b/test/html/polymer-selector-basic.html index b12dcf5..93f0d62 100644 --- a/test/html/polymer-selector-basic.html +++ b/test/html/polymer-selector-basic.html @@ -50,7 +50,34 @@ s = document.querySelector('#selector2'); assert.equal(s.selected, "item3"); assert.equal(s.selectedClass, 'my-selected'); - done(); + // setup listener for polymer-select event + var selectEventCounter = 0; + s.addEventListener('polymer-select', function(e) { + if (e.detail.isSelected) { + selectEventCounter++; + // selectedItem and detail.item should be the same + assert.equal(e.detail.item, s.selectedItem); + } + }); + // set selected + s.selected = 'item5'; + Platform.flush(); + setTimeout(function() { + // check polymer-select event + assert.equal(selectEventCounter, 1); + // check selected class + assert.isTrue(s.children[4].classList.contains('my-selected')); + // check selectedItem + assert.equal(s.selectedItem, s.children[4]); + // selecting the same value shouldn't fire polymer-select + selectEventCounter = 0; + s.selected = 'item5'; + Platform.flush(); + setTimeout(function() { + assert.equal(selectEventCounter, 0); + done(); + }.bind(this), 0); + }.bind(this), 0); }); diff --git a/test/html/polymer-selector-multi.html b/test/html/polymer-selector-multi.html index bd49877..a94f820 100644 --- a/test/html/polymer-selector-multi.html +++ b/test/html/polymer-selector-multi.html @@ -32,20 +32,36 @@ assert.isTrue(s.multi); assert.equal(s.valueattr, 'name'); assert.equal(s.items.length, 5); - // - var eventCounter = 0; + // setup listener for polymer-select event + var selectEventCounter = 0; s.addEventListener('polymer-select', function(e) { if (e.detail.isSelected) { - eventCounter++; + selectEventCounter++; + } else { + selectEventCounter--; } + // check selectedItem in polymer-select event + assert.equal(this.selectedItem.length, selectEventCounter); }); setTimeout(function() { + // set selected s.selected = [0, 2]; Platform.flush(); setTimeout(function() { - assert.equal(eventCounter, 2); + // check polymer-select event + assert.equal(selectEventCounter, 2); + // check selected class assert.isTrue(s.children[0].classList.contains('polymer-selected')); assert.isTrue(s.children[2].classList.contains('polymer-selected')); + // check selectedItem + assert.equal(s.selectedItem.length, 2); + assert.equal(s.selectedItem[0], s.children[0]); + assert.equal(s.selectedItem[1], s.children[2]); + // tap on already selected element should unselect it + s.children[0].dispatchEvent(new CustomEvent('tap', {bubbles: true})); + // check selected + assert.equal(s.selected.length, 1); + assert.isFalse(s.children[0].classList.contains('polymer-selected')); done(); }.bind(this), 0); }.bind(this), 0); From 749180818e03c9f892c39ac40856e20eb0a1f73f Mon Sep 17 00:00:00 2001 From: "Scott J. Miles" Date: Mon, 12 Aug 2013 15:58:50 -0700 Subject: [PATCH 03/15] use local url for sample, bubble the internal signal event so it's not lost to the on-* delegation mechanism; TODO: dudupe the signals wrt bubbling --- polymer-signals/index.html | 4 ++-- polymer-signals/polymer-signals.html | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/polymer-signals/index.html b/polymer-signals/index.html index 5e067cd..8f06c54 100644 --- a/polymer-signals/index.html +++ b/polymer-signals/index.html @@ -2,7 +2,7 @@ - + @@ -13,7 +13,7 @@ diff --git a/test/html/polymer-selector-basic.html b/test/html/polymer-selector-basic.html index 93f0d62..681e8ea 100644 --- a/test/html/polymer-selector-basic.html +++ b/test/html/polymer-selector-basic.html @@ -62,7 +62,7 @@ // set selected s.selected = 'item5'; Platform.flush(); - setTimeout(function() { + Platform.endOfMicrotask(function() { // check polymer-select event assert.equal(selectEventCounter, 1); // check selected class @@ -73,11 +73,11 @@ selectEventCounter = 0; s.selected = 'item5'; Platform.flush(); - setTimeout(function() { + Platform.endOfMicrotask(function() { assert.equal(selectEventCounter, 0); done(); - }.bind(this), 0); - }.bind(this), 0); + }); + }); }); diff --git a/test/html/polymer-selector-multi.html b/test/html/polymer-selector-multi.html index a94f820..d647cf0 100644 --- a/test/html/polymer-selector-multi.html +++ b/test/html/polymer-selector-multi.html @@ -43,11 +43,11 @@ // check selectedItem in polymer-select event assert.equal(this.selectedItem.length, selectEventCounter); }); - setTimeout(function() { + Platform.endOfMicrotask(function() { // set selected s.selected = [0, 2]; Platform.flush(); - setTimeout(function() { + Platform.endOfMicrotask(function() { // check polymer-select event assert.equal(selectEventCounter, 2); // check selected class @@ -63,8 +63,8 @@ assert.equal(s.selected.length, 1); assert.isFalse(s.children[0].classList.contains('polymer-selected')); done(); - }.bind(this), 0); - }.bind(this), 0); + }); + }); }); From a859e356e40b9a18cb77fda070aa4b7987577f27 Mon Sep 17 00:00:00 2001 From: Yvonne Yip Date: Tue, 13 Aug 2013 18:40:27 -0700 Subject: [PATCH 08/15] polymer-anchor-position: anchor-position polyfill --- polymer-anchor-position/index.html | 67 +++++++++++ .../polymer-anchor-position.html | 112 ++++++++++++++++++ 2 files changed, 179 insertions(+) create mode 100644 polymer-anchor-position/index.html create mode 100644 polymer-anchor-position/polymer-anchor-position.html diff --git a/polymer-anchor-position/index.html b/polymer-anchor-position/index.html new file mode 100644 index 0000000..e569623 --- /dev/null +++ b/polymer-anchor-position/index.html @@ -0,0 +1,67 @@ + + + + polymer-anchor-position + + + + + + + + +
+ + + +
+ +
+ +
+
+ + + +
+ +
+
+
+ + + + diff --git a/polymer-anchor-position/polymer-anchor-position.html b/polymer-anchor-position/polymer-anchor-position.html new file mode 100644 index 0000000..0625885 --- /dev/null +++ b/polymer-anchor-position/polymer-anchor-position.html @@ -0,0 +1,112 @@ + + + + From f0d6941708a973f9301aad546d84f0b28d833244 Mon Sep 17 00:00:00 2001 From: Yvonne Yip Date: Wed, 14 Aug 2013 11:48:39 -0700 Subject: [PATCH 09/15] polymer-anchor-position -> polymer-anchor-point --- .../index.html | 24 ++++----- .../polymer-anchor-point.html | 52 +++++++++---------- 2 files changed, 38 insertions(+), 38 deletions(-) rename {polymer-anchor-position => polymer-anchor-point}/index.html (57%) rename polymer-anchor-position/polymer-anchor-position.html => polymer-anchor-point/polymer-anchor-point.html (59%) diff --git a/polymer-anchor-position/index.html b/polymer-anchor-point/index.html similarity index 57% rename from polymer-anchor-position/index.html rename to polymer-anchor-point/index.html index e569623..70abd82 100644 --- a/polymer-anchor-position/index.html +++ b/polymer-anchor-point/index.html @@ -1,10 +1,10 @@ - polymer-anchor-position + polymer-anchor-point - +