Skip to content

Commit

Permalink
check for parentElement for sandbox analytics (ampproject#12746)
Browse files Browse the repository at this point in the history
  • Loading branch information
zhouyx authored and RanAbram committed Mar 12, 2018
1 parent 8a3ba6d commit 7a82e30
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions extensions/amp-analytics/0.1/amp-analytics.js
Expand Up @@ -305,6 +305,10 @@ export class AmpAnalytics extends AMP.BaseElement {
// replace selector and selectionMethod
if (this.isSandbox_) {
// Only support selection of parent element for analytics in scope
if (!this.element.parentElement) {
// In case parent element has been removed from DOM, do nothing
return;
}
trigger['selector'] = this.element.parentElement.tagName;
trigger['selectionMethod'] = 'closest';
this.addTriggerNoInline_(trigger);
Expand Down

0 comments on commit 7a82e30

Please sign in to comment.