{"action":"created","comment":{"url":"https://api.github.com/repos/ampproject/amphtml/pulls/comments/175884421","pull_request_review_id":105489791,"id":175884421,"diff_hunk":"@@ -113,10 +112,66 @@ export class A4AVariableSource extends VariableSource {\n       return getNavigationData(this.win_, 'redirectCount');\n     });\n \n+    this.set('HTML_ATTR',\n+        /** @type {function(...*)} */(this.htmlAttrBinding_.bind(this)));\n+\n     for (let v = 0; v < WHITELISTED_VARIABLES.length; v++) {\n       const varName = WHITELISTED_VARIABLES[v];\n       const resolvers = this.globalVariableSource_.get(varName);\n       this.set(varName, resolvers.sync).setAsync(varName, resolvers.async);\n     }\n   }\n+\n+  /**\n+   * Provides a binding for getting attributes from the DOM.\n+   * Most such bindings are provided in src/service/url-replacements-impl, but\n+   * this one needs access to this.win_.document, which if the amp-analytics\n+   * tag is contained within an amp-ad tag will NOT be the parent/publisher\n+   * page. Hence the need to put it here.\n+   * @param {string} cssSelector Elements matching this selector will be\n+   *     included, provided they have at least one of the attributeNames\n+   *     set, up to a max of 10. May be URI encoded.\n+   * Note: Additional params will be the names of the attributes whose values\n+   * will be returned. There should be at least 1.\n+   * @returns {string} A stringified JSON array containing one member for each\n+   *     matching element. Each member will contain the names and values of the\n+   *     specified attributes, if the corresponding element has that attribute.\n+   *     Note that if an element matches the cssSelected but has none of the\n+   *     requested attributes, then nothing will be included in the array\n+   *     for that element.\n+   */\n+  htmlAttrBinding_(cssSelector) {\n+    const HTML_ATTR_MAX_RETURN_SIZE = 10;\n+    const attributeNames = Array.prototype.slice.call(arguments, 1);\n+    if (!cssSelector || !attributeNames.length) {\n+      return '[]';\n+    }\n+    cssSelector = decodeURI(cssSelector);\n+    let elements;\n+    try {\n+      elements = this.win_.document.querySelectorAll(cssSelector);\n+    } catch (e) {\n+      const TAG = 'A4AVariableSource';\n+      user().warn(TAG, `Invalid selector: ${cssSelector}`);\n+      return '[]';\n+    }\n+    const result = [];\n+    for (let i = 0; i < elements.length &&\n+        result.length < HTML_ATTR_MAX_RETURN_SIZE; ++i) {","path":"extensions/amp-a4a/0.1/a4a-variable-source.js","position":null,"original_position":57,"commit_id":"34e562884399f07d0f2d1704fd72474b6dcfb5ce","original_commit_id":"ce54b3d537021df7ffc5bd2c97d22ddf80a0f3b9","user":{"login":"jonkeller","id":2455047,"avatar_url":"https://avatars1.githubusercontent.com/u/2455047?v=4","gravatar_id":"","url":"https://api.github.com/users/jonkeller","html_url":"https://github.com/jonkeller","followers_url":"https://api.github.com/users/jonkeller/followers","following_url":"https://api.github.com/users/jonkeller/following{/other_user}","gists_url":"https://api.github.com/users/jonkeller/gists{/gist_id}","starred_url":"https://api.github.com/users/jonkeller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonkeller/subscriptions","organizations_url":"https://api.github.com/users/jonkeller/orgs","repos_url":"https://api.github.com/users/jonkeller/repos","events_url":"https://api.github.com/users/jonkeller/events{/privacy}","received_events_url":"https://api.github.com/users/jonkeller/received_events","type":"User","site_admin":false},"body":"Good question! Renamed HTML_ATTR_MAX_RETURN_SIZE to HTML_ATTR_MAX_ELEMENTS, and added new HTML_ATTR_MAX_ATTRS.","created_at":"2018-03-20T18:52:02Z","updated_at":"2018-03-20T18:52:03Z","html_url":"https://github.com/ampproject/amphtml/pull/13712#discussion_r175884421","pull_request_url":"https://api.github.com/repos/ampproject/amphtml/pulls/13712","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/comments/175884421"},"html":{"href":"https://github.com/ampproject/amphtml/pull/13712#discussion_r175884421"},"pull_request":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/13712"}},"in_reply_to_id":175597035},"pull_request":{"url":"https://api.github.com/repos/ampproject/amphtml/pulls/13712","id":171998399,"html_url":"https://github.com/ampproject/amphtml/pull/13712","diff_url":"https://github.com/ampproject/amphtml/pull/13712.diff","patch_url":"https://github.com/ampproject/amphtml/pull/13712.patch","issue_url":"https://api.github.com/repos/ampproject/amphtml/issues/13712","number":13712,"state":"open","locked":false,"title":"Get creative content","user":{"login":"jonkeller","id":2455047,"avatar_url":"https://avatars1.githubusercontent.com/u/2455047?v=4","gravatar_id":"","url":"https://api.github.com/users/jonkeller","html_url":"https://github.com/jonkeller","followers_url":"https://api.github.com/users/jonkeller/followers","following_url":"https://api.github.com/users/jonkeller/following{/other_user}","gists_url":"https://api.github.com/users/jonkeller/gists{/gist_id}","starred_url":"https://api.github.com/users/jonkeller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonkeller/subscriptions","organizations_url":"https://api.github.com/users/jonkeller/orgs","repos_url":"https://api.github.com/users/jonkeller/repos","events_url":"https://api.github.com/users/jonkeller/events{/privacy}","received_events_url":"https://api.github.com/users/jonkeller/received_events","type":"User","site_admin":false},"body":"Allows amp-analytics request to include htmlAttr expansion variable. Example:\r\n${htmlAttr(img,src,width)}\r\n...to get the src and width attrs of images. Documentation to follow in separate PR.\r\nCaveats:\r\n\r\nOnly up to 10 matching elements will be returned.\r\nAn element counts as a match if it matches the CSS query selector (first arg) and has one or more of the attrs specified in the remaining args\r\n\r\nCloned from #13111 ","created_at":"2018-02-28T16:08:28Z","updated_at":"2018-03-20T18:52:03Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1c5716a797a835b329d3eff0f335f59ad998add8","assignee":{"login":"jonkeller","id":2455047,"avatar_url":"https://avatars1.githubusercontent.com/u/2455047?v=4","gravatar_id":"","url":"https://api.github.com/users/jonkeller","html_url":"https://github.com/jonkeller","followers_url":"https://api.github.com/users/jonkeller/followers","following_url":"https://api.github.com/users/jonkeller/following{/other_user}","gists_url":"https://api.github.com/users/jonkeller/gists{/gist_id}","starred_url":"https://api.github.com/users/jonkeller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonkeller/subscriptions","organizations_url":"https://api.github.com/users/jonkeller/orgs","repos_url":"https://api.github.com/users/jonkeller/repos","events_url":"https://api.github.com/users/jonkeller/events{/privacy}","received_events_url":"https://api.github.com/users/jonkeller/received_events","type":"User","site_admin":false},"assignees":[{"login":"jonkeller","id":2455047,"avatar_url":"https://avatars1.githubusercontent.com/u/2455047?v=4","gravatar_id":"","url":"https://api.github.com/users/jonkeller","html_url":"https://github.com/jonkeller","followers_url":"https://api.github.com/users/jonkeller/followers","following_url":"https://api.github.com/users/jonkeller/following{/other_user}","gists_url":"https://api.github.com/users/jonkeller/gists{/gist_id}","starred_url":"https://api.github.com/users/jonkeller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonkeller/subscriptions","organizations_url":"https://api.github.com/users/jonkeller/orgs","repos_url":"https://api.github.com/users/jonkeller/repos","events_url":"https://api.github.com/users/jonkeller/events{/privacy}","received_events_url":"https://api.github.com/users/jonkeller/received_events","type":"User","site_admin":false}],"requested_reviewers":[],"requested_teams":[],"labels":[{"id":283436627,"url":"https://api.github.com/repos/ampproject/amphtml/labels/Category:%20Ads","name":"Category: Ads","color":"1d76db","default":false},{"id":596633554,"url":"https://api.github.com/repos/ampproject/amphtml/labels/cla:%20yes","name":"cla: yes","color":"ededed","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ampproject/amphtml/pulls/13712/commits","review_comments_url":"https://api.github.com/repos/ampproject/amphtml/pulls/13712/comments","review_comment_url":"https://api.github.com/repos/ampproject/amphtml/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ampproject/amphtml/issues/13712/comments","statuses_url":"https://api.github.com/repos/ampproject/amphtml/statuses/34e562884399f07d0f2d1704fd72474b6dcfb5ce","head":{"label":"jonkeller:get-creative-content-7","ref":"get-creative-content-7","sha":"34e562884399f07d0f2d1704fd72474b6dcfb5ce","user":{"login":"jonkeller","id":2455047,"avatar_url":"https://avatars1.githubusercontent.com/u/2455047?v=4","gravatar_id":"","url":"https://api.github.com/users/jonkeller","html_url":"https://github.com/jonkeller","followers_url":"https://api.github.com/users/jonkeller/followers","following_url":"https://api.github.com/users/jonkeller/following{/other_user}","gists_url":"https://api.github.com/users/jonkeller/gists{/gist_id}","starred_url":"https://api.github.com/users/jonkeller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonkeller/subscriptions","organizations_url":"https://api.github.com/users/jonkeller/orgs","repos_url":"https://api.github.com/users/jonkeller/repos","events_url":"https://api.github.com/users/jonkeller/events{/privacy}","received_events_url":"https://api.github.com/users/jonkeller/received_events","type":"User","site_admin":false},"repo":{"id":107277373,"name":"amphtml","full_name":"jonkeller/amphtml","owner":{"login":"jonkeller","id":2455047,"avatar_url":"https://avatars1.githubusercontent.com/u/2455047?v=4","gravatar_id":"","url":"https://api.github.com/users/jonkeller","html_url":"https://github.com/jonkeller","followers_url":"https://api.github.com/users/jonkeller/followers","following_url":"https://api.github.com/users/jonkeller/following{/other_user}","gists_url":"https://api.github.com/users/jonkeller/gists{/gist_id}","starred_url":"https://api.github.com/users/jonkeller/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jonkeller/subscriptions","organizations_url":"https://api.github.com/users/jonkeller/orgs","repos_url":"https://api.github.com/users/jonkeller/repos","events_url":"https://api.github.com/users/jonkeller/events{/privacy}","received_events_url":"https://api.github.com/users/jonkeller/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jonkeller/amphtml","description":"AMP HTML source code, samples, and documentation.  See below for more info.","fork":true,"url":"https://api.github.com/repos/jonkeller/amphtml","forks_url":"https://api.github.com/repos/jonkeller/amphtml/forks","keys_url":"https://api.github.com/repos/jonkeller/amphtml/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jonkeller/amphtml/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jonkeller/amphtml/teams","hooks_url":"https://api.github.com/repos/jonkeller/amphtml/hooks","issue_events_url":"https://api.github.com/repos/jonkeller/amphtml/issues/events{/number}","events_url":"https://api.github.com/repos/jonkeller/amphtml/events","assignees_url":"https://api.github.com/repos/jonkeller/amphtml/assignees{/user}","branches_url":"https://api.github.com/repos/jonkeller/amphtml/branches{/branch}","tags_url":"https://api.github.com/repos/jonkeller/amphtml/tags","blobs_url":"https://api.github.com/repos/jonkeller/amphtml/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jonkeller/amphtml/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jonkeller/amphtml/git/refs{/sha}","trees_url":"https://api.github.com/repos/jonkeller/amphtml/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jonkeller/amphtml/statuses/{sha}","languages_url":"https://api.github.com/repos/jonkeller/amphtml/languages","stargazers_url":"https://api.github.com/repos/jonkeller/amphtml/stargazers","contributors_url":"https://api.github.com/repos/jonkeller/amphtml/contributors","subscribers_url":"https://api.github.com/repos/jonkeller/amphtml/subscribers","subscription_url":"https://api.github.com/repos/jonkeller/amphtml/subscription","commits_url":"https://api.github.com/repos/jonkeller/amphtml/commits{/sha}","git_commits_url":"https://api.github.com/repos/jonkeller/amphtml/git/commits{/sha}","comments_url":"https://api.github.com/repos/jonkeller/amphtml/comments{/number}","issue_comment_url":"https://api.github.com/repos/jonkeller/amphtml/issues/comments{/number}","contents_url":"https://api.github.com/repos/jonkeller/amphtml/contents/{+path}","compare_url":"https://api.github.com/repos/jonkeller/amphtml/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jonkeller/amphtml/merges","archive_url":"https://api.github.com/repos/jonkeller/amphtml/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jonkeller/amphtml/downloads","issues_url":"https://api.github.com/repos/jonkeller/amphtml/issues{/number}","pulls_url":"https://api.github.com/repos/jonkeller/amphtml/pulls{/number}","milestones_url":"https://api.github.com/repos/jonkeller/amphtml/milestones{/number}","notifications_url":"https://api.github.com/repos/jonkeller/amphtml/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jonkeller/amphtml/labels{/name}","releases_url":"https://api.github.com/repos/jonkeller/amphtml/releases{/id}","deployments_url":"https://api.github.com/repos/jonkeller/amphtml/deployments","created_at":"2017-10-17T14:08:46Z","updated_at":"2017-10-17T14:08:57Z","pushed_at":"2018-03-20T18:51:43Z","git_url":"git://github.com/jonkeller/amphtml.git","ssh_url":"git@github.com:jonkeller/amphtml.git","clone_url":"https://github.com/jonkeller/amphtml.git","svn_url":"https://github.com/jonkeller/amphtml","homepage":"https://www.ampproject.org","size":414260,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":null,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"ampproject:master","ref":"master","sha":"e295fad1ebc926655b5a24a945123d5ae66b5925","user":{"login":"ampproject","id":14114390,"avatar_url":"https://avatars3.githubusercontent.com/u/14114390?v=4","gravatar_id":"","url":"https://api.github.com/users/ampproject","html_url":"https://github.com/ampproject","followers_url":"https://api.github.com/users/ampproject/followers","following_url":"https://api.github.com/users/ampproject/following{/other_user}","gists_url":"https://api.github.com/users/ampproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ampproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ampproject/subscriptions","organizations_url":"https://api.github.com/users/ampproject/orgs","repos_url":"https://api.github.com/users/ampproject/repos","events_url":"https://api.github.com/users/ampproject/events{/privacy}","received_events_url":"https://api.github.com/users/ampproject/received_events","type":"Organization","site_admin":false},"repo":{"id":41766002,"name":"amphtml","full_name":"ampproject/amphtml","owner":{"login":"ampproject","id":14114390,"avatar_url":"https://avatars3.githubusercontent.com/u/14114390?v=4","gravatar_id":"","url":"https://api.github.com/users/ampproject","html_url":"https://github.com/ampproject","followers_url":"https://api.github.com/users/ampproject/followers","following_url":"https://api.github.com/users/ampproject/following{/other_user}","gists_url":"https://api.github.com/users/ampproject/gists{/gist_id}","starred_url":"https://api.github.com/users/ampproject/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ampproject/subscriptions","organizations_url":"https://api.github.com/users/ampproject/orgs","repos_url":"https://api.github.com/users/ampproject/repos","events_url":"https://api.github.com/users/ampproject/events{/privacy}","received_events_url":"https://api.github.com/users/ampproject/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ampproject/amphtml","description":"AMP HTML source code, samples, and documentation.  See below for more info.","fork":false,"url":"https://api.github.com/repos/ampproject/amphtml","forks_url":"https://api.github.com/repos/ampproject/amphtml/forks","keys_url":"https://api.github.com/repos/ampproject/amphtml/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ampproject/amphtml/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ampproject/amphtml/teams","hooks_url":"https://api.github.com/repos/ampproject/amphtml/hooks","issue_events_url":"https://api.github.com/repos/ampproject/amphtml/issues/events{/number}","events_url":"https://api.github.com/repos/ampproject/amphtml/events","assignees_url":"https://api.github.com/repos/ampproject/amphtml/assignees{/user}","branches_url":"https://api.github.com/repos/ampproject/amphtml/branches{/branch}","tags_url":"https://api.github.com/repos/ampproject/amphtml/tags","blobs_url":"https://api.github.com/repos/ampproject/amphtml/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ampproject/amphtml/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ampproject/amphtml/git/refs{/sha}","trees_url":"https://api.github.com/repos/ampproject/amphtml/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ampproject/amphtml/statuses/{sha}","languages_url":"https://api.github.com/repos/ampproject/amphtml/languages","stargazers_url":"https://api.github.com/repos/ampproject/amphtml/stargazers","contributors_url":"https://api.github.com/repos/ampproject/amphtml/contributors","subscribers_url":"https://api.github.com/repos/ampproject/amphtml/subscribers","subscription_url":"https://api.github.com/repos/ampproject/amphtml/subscription","commits_url":"https://api.github.com/repos/ampproject/amphtml/commits{/sha}","git_commits_url":"https://api.github.com/repos/ampproject/amphtml/git/commits{/sha}","comments_url":"https://api.github.com/repos/ampproject/amphtml/comments{/number}","issue_comment_url":"https://api.github.com/repos/ampproject/amphtml/issues/comments{/number}","contents_url":"https://api.github.com/repos/ampproject/amphtml/contents/{+path}","compare_url":"https://api.github.com/repos/ampproject/amphtml/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ampproject/amphtml/merges","archive_url":"https://api.github.com/repos/ampproject/amphtml/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ampproject/amphtml/downloads","issues_url":"https://api.github.com/repos/ampproject/amphtml/issues{/number}","pulls_url":"https://api.github.com/repos/ampproject/amphtml/pulls{/number}","milestones_url":"https://api.github.com/repos/ampproject/amphtml/milestones{/number}","notifications_url":"https://api.github.com/repos/ampproject/amphtml/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ampproject/amphtml/labels{/name}","releases_url":"https://api.github.com/repos/ampproject/amphtml/releases{/id}","deployments_url":"https://api.github.com/repos/ampproject/amphtml/deployments","created_at":"2015-09-01T22:10:53Z","updated_at":"2018-03-20T18:16:03Z","pushed_at":"2018-03-20T18:51:45Z","git_url":"git://github.com/ampproject/amphtml.git","ssh_url":"git@github.com:ampproject/amphtml.git","clone_url":"https://github.com/ampproject/amphtml.git","svn_url":"https://github.com/ampproject/amphtml","homepage":"https://www.ampproject.org","size":415211,"stargazers_count":11341,"watchers_count":11341,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":2295,"mirror_url":null,"archived":false,"open_issues_count":1210,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0"},"forks":2295,"open_issues":1210,"watchers":11341,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/13712"},"html":{"href":"https://github.com/ampproject/amphtml/pull/13712"},"issue":{"href":"https://api.github.com/repos/ampproject/amphtml/issues/13712"},"comments":{"href":"https://api.github.com/repos/ampproject/amphtml/issues/13712/comments"},"review_comments":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/13712/comments"},"review_comment":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ampproject/amphtml/pulls/13712/commits"},"statuses":{"href":"https://api.github.com/repos/ampproject/amphtml/statuses/34e562884399f07d0f2d1704fd72474b6dcfb5ce"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"jonkeller"}}