@@ -5,6 +5,7 @@ import { defineCustomElement } from '@components/scripts/utils'
55import { handleScriptError } from '@components/scripts/errors/handler'
66import type { WebComponentModule } from '@components/scripts/@types/webComponentModule'
77import type { WebmentionDisplayItem , WebmentionsListResult } from '@actions/webmentions/@types'
8+ import { queryWebMentionsIconMarkup } from './selectors'
89
910type LoadState = 'idle' | 'loading' | 'ready' | 'error'
1011
@@ -22,17 +23,6 @@ const formatDate = (dateString: string): string => {
2223 } ) . format ( date )
2324}
2425
25- const queryIconMarkup = ( iconBankId : string , iconName : string ) : string | null => {
26- if ( typeof document === 'undefined' ) {
27- return null
28- }
29-
30- const iconBank = document . getElementById ( iconBankId )
31- const iconHost = iconBank ?. querySelector ( `[data-webmentions-icon="${ iconName } "]` )
32- const markup = iconHost ?. innerHTML . trim ( )
33- return markup ? markup : null
34- }
35-
3626export class WebMentionsElement extends LitElement {
3727 static registeredName = 'web-mentions'
3828
@@ -149,8 +139,14 @@ export class WebMentionsElement extends LitElement {
149139
150140 const newestMentions = [ ...this . mentions ] . reverse ( )
151141 const facepileMentions = newestMentions . slice ( 0 , this . facepileLimit ) . reverse ( )
152- const heartIconMarkup = queryIconMarkup ( this . iconBankId , 'heart-filled' )
153- const repostIconMarkup = queryIconMarkup ( this . iconBankId , 'background-broken' )
142+ const heartIconMarkup = queryWebMentionsIconMarkup ( {
143+ iconBankId : this . iconBankId ,
144+ iconName : 'heart-filled' ,
145+ } )
146+ const repostIconMarkup = queryWebMentionsIconMarkup ( {
147+ iconBankId : this . iconBankId ,
148+ iconName : 'background-broken' ,
149+ } )
154150
155151 return html `
156152 < section class ="mt-12 pt-8 border-t border-trim " id ="webmentions " aria-labelledby ="webmentions-heading ">
0 commit comments