Skip to content

Commit

Permalink
Move up check for DOMNodeList
Browse files Browse the repository at this point in the history
  • Loading branch information
westonruter authored Oct 27, 2022
1 parent e50ee5b commit aeacc33
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions includes/sanitizers/class-amp-gtag-script-sanitizer.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,12 @@ public function sanitize() {
* </script>
*/
$scripts = $this->dom->xpath->query( '//script[ ( @async and starts-with( @src, "https://www.googletagmanager.com/gtag/js" ) ) or contains( text(), "function gtag(" ) ]' );

if ( 0 === $scripts->length ) {
if ( ! $scripts instanceof DOMNodeList || 0 === $scripts->length ) {
return;
}

if ( $scripts instanceof DOMNodeList ) {
foreach ( $scripts as $script ) {
ValidationExemption::mark_node_as_px_verified( $script );
}
foreach ( $scripts as $script ) {
ValidationExemption::mark_node_as_px_verified( $script );
}

/**
Expand Down

0 comments on commit aeacc33

Please sign in to comment.