From 10a7ae44076b5d4a30dd8fa473b003fd7686d2f5 Mon Sep 17 00:00:00 2001 From: Hector Carmona Date: Wed, 9 Oct 2019 16:33:18 -0700 Subject: [PATCH 1/3] Populate aria-owns attribute on iron-list + test --- iron-list.js | 7 +++++++ test/basic.html | 34 +++++++++++++++++++++++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) diff --git a/iron-list.js b/iron-list.js index 3ecff251..af67273b 100644 --- a/iron-list.js +++ b/iron-list.js @@ -1323,10 +1323,17 @@ Polymer({ } }); } else { + let order = []; this._iterateItems(function(pidx, vidx) { this.translate3d(0, y + 'px', 0, this._physicalItems[pidx]); y += this._physicalSizes[pidx]; + if (this._physicalItems[pidx].id) { + order.push(this._physicalItems[pidx].id); + } }); + if (order.length) { + this.setAttribute('aria-owns', order.join(' ')); + } } }, diff --git a/test/basic.html b/test/basic.html index 0b0cfdd5..b4804082 100644 --- a/test/basic.html +++ b/test/basic.html @@ -20,7 +20,7 @@ @@ -145,6 +145,38 @@ assert.equal(list.firstVisibleIndex, 99); }); + test('expected aria-owns while scrolling', function() { + list.items = buildDataSet(100); + PolymerFlush(); + + const getExpectedAriaOwns = () => { + return + // Physical children. + Array.from(list.querySelectorAll('x-list')) + + // Skip selected node. + .filter(child => child.getBoundingClientRect().top >= -10000) + + // Sort by |top|. + .sort((left, right) => left.getBoundingClientRect().top - right.getBoundingClientRect().top) + + // Get IDs. + .map(child => child.id) + + // Create expected |aria-owned|. + .join(' '); + }; + + // Make sure we're virtualizing nodes. + assert.isTrue(Array.from(list.querySelectorAll('x-list')).length < list.items.length); + + // Scroll by 7 because it's not a 'nice round number'. + for (let i = 0; i < list.items.length; i += 7) { + list.scrollToIndex(i); + assert.equal(list.getAttribute('aria-owns'), getExpectedAriaOwns()); + } + }); + test('scroll to index while not attached', function() { var tmpList = document.createElement('iron-list'); dom(tmpList).appendChild(document.createElement('template')); From 5eb282e138fc69ccbf6ff21457914c0ad91b9d63 Mon Sep 17 00:00:00 2001 From: Hector Carmona Date: Thu, 10 Oct 2019 11:06:22 -0700 Subject: [PATCH 2/3] Format and Update test --- test/basic.html | 14 +++++++++----- test/fixtures/x-list.js | 2 +- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/test/basic.html b/test/basic.html index b4804082..c78b2789 100644 --- a/test/basic.html +++ b/test/basic.html @@ -20,7 +20,7 @@ @@ -150,15 +150,18 @@ PolymerFlush(); const getExpectedAriaOwns = () => { - return + return Array // Physical children. - Array.from(list.querySelectorAll('x-list')) + .from(list.querySelectorAll('div.item')) // Skip selected node. .filter(child => child.getBoundingClientRect().top >= -10000) // Sort by |top|. - .sort((left, right) => left.getBoundingClientRect().top - right.getBoundingClientRect().top) + .sort((left, right) => { + return left.getBoundingClientRect().top - + right.getBoundingClientRect().top; + }) // Get IDs. .map(child => child.id) @@ -168,7 +171,8 @@ }; // Make sure we're virtualizing nodes. - assert.isTrue(Array.from(list.querySelectorAll('x-list')).length < list.items.length); + assert.isTrue(list.querySelectorAll('div.item').length < list.items.length); + assert.isTrue(list.querySelectorAll('div.item').length > 0); // Scroll by 7 because it's not a 'nice round number'. for (let i = 0; i < list.items.length; i += 7) { diff --git a/test/fixtures/x-list.js b/test/fixtures/x-list.js index e6d39c3c..9a77e978 100644 --- a/test/fixtures/x-list.js +++ b/test/fixtures/x-list.js @@ -41,7 +41,7 @@ Polymer({