Skip to content
This repository has been archived by the owner on Jun 7, 2024. It is now read-only.

Commit

Permalink
Fix hovercards appear on non-avatar images
Browse files Browse the repository at this point in the history
  • Loading branch information
wellyshen committed Aug 10, 2023
1 parent 3db822c commit 3a58ea7
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,14 +133,15 @@ export default class Hovercards {
let refs: HTMLElement[] = [];
const camelAttrName = dataAttributeName.replace( /-([a-z])/g, ( g ) => g[ 1 ].toUpperCase() );
const ignoreRefs = ignoreSelector ? Array.from( dc.querySelectorAll( ignoreSelector ) ) : [];
const matchPath = 'gravatar.com/avatar/';

if (
target.dataset[ camelAttrName ] ||
( target.tagName === 'IMG' && ( target as HTMLImageElement ).src.includes( 'gravatar.com/' ) )
( target.tagName === 'IMG' && ( target as HTMLImageElement ).src.includes( matchPath ) )
) {
refs = [ target ];
} else {
refs = Array.from( target.querySelectorAll( 'img[src*="gravatar.com/"]' ) );
refs = Array.from( target.querySelectorAll( `img[src*="${ matchPath }"]` ) );

if ( dataAttributeName ) {
refs = [
Expand Down

0 comments on commit 3a58ea7

Please sign in to comment.