From 3726d5eb425532c2db3e438e06192bacf453c8c6 Mon Sep 17 00:00:00 2001 From: Dima Voytenko Date: Thu, 26 May 2016 11:34:09 -0700 Subject: [PATCH] Allow non-alpha IDs to be used for access sections --- extensions/amp-access/0.1/amp-access-server.js | 2 +- .../amp-access/0.1/test/test-amp-access-server.js | 12 ++++++------ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/extensions/amp-access/0.1/amp-access-server.js b/extensions/amp-access/0.1/amp-access-server.js index 15bfb8eb810c..7098e4680ba5 100644 --- a/extensions/amp-access/0.1/amp-access-server.js +++ b/extensions/amp-access/0.1/amp-access-server.js @@ -192,7 +192,7 @@ export class AccessServerAdapter { const section = sections[i]; const sectionId = section.getAttribute('i-amp-access-id'); const target = this.win.document.querySelector( - '[i-amp-access-id=' + sectionId + ']'); + '[i-amp-access-id="' + sectionId + '"]'); if (!target) { dev.warn(TAG, 'Section not found: ', sectionId); continue; diff --git a/extensions/amp-access/0.1/test/test-amp-access-server.js b/extensions/amp-access/0.1/test/test-amp-access-server.js index 52e322f296cf..e7917994c637 100644 --- a/extensions/amp-access/0.1/test/test-amp-access-server.js +++ b/extensions/amp-access/0.1/test/test-amp-access-server.js @@ -115,11 +115,11 @@ describe('AccessServerAdapter', () => { responseDoc.appendChild(responseAccessData); targetElement1 = document.createElement('div'); - targetElement1.setAttribute('i-amp-access-id', 'a1'); + targetElement1.setAttribute('i-amp-access-id', '1/1'); document.body.appendChild(targetElement1); targetElement2 = document.createElement('div'); - targetElement2.setAttribute('i-amp-access-id', 'a2'); + targetElement2.setAttribute('i-amp-access-id', '1/2'); document.body.appendChild(targetElement2); }); @@ -266,12 +266,12 @@ describe('AccessServerAdapter', () => { it('should replace sections', () => { const responseElement1 = document.createElement('div'); - responseElement1.setAttribute('i-amp-access-id', 'a1'); + responseElement1.setAttribute('i-amp-access-id', '1/1'); responseElement1.textContent = 'a1'; responseDoc.appendChild(responseElement1); const responseElement2 = document.createElement('div'); - responseElement2.setAttribute('i-amp-access-id', 'a2'); + responseElement2.setAttribute('i-amp-access-id', '1/2'); responseElement2.textContent = 'a2'; responseDoc.appendChild(responseElement2); @@ -281,9 +281,9 @@ describe('AccessServerAdapter', () => { responseDoc.appendChild(unknownResponseElement3); return adapter.replaceSections_(responseDoc).then(() => { - expect(document.querySelector('[i-amp-access-id=a1]').textContent) + expect(document.querySelector('[i-amp-access-id="1/1"]').textContent) .to.equal('a1'); - expect(document.querySelector('[i-amp-access-id=a2]').textContent) + expect(document.querySelector('[i-amp-access-id="1/2"]').textContent) .to.equal('a2'); expect(document.querySelector('[i-amp-access-id=a3]')).to.be.null; });