From 09fcfab98ab8c9c5a24135b09c31d6163fcdce09 Mon Sep 17 00:00:00 2001 From: Nicolas Constant Date: Sun, 7 Jul 2019 14:14:12 -0400 Subject: [PATCH] databind all found elements, fix the hashtags bug --- .../databinded-text.component.ts | 59 +++++++++++-------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/src/app/components/stream/status/databinded-text/databinded-text.component.ts b/src/app/components/stream/status/databinded-text/databinded-text.component.ts index e4b4c8aa..18dcc357 100644 --- a/src/app/components/stream/status/databinded-text/databinded-text.component.ts +++ b/src/app/components/stream/status/databinded-text/databinded-text.component.ts @@ -159,50 +159,57 @@ export class DatabindedTextComponent implements OnInit { ngAfterViewInit() { for (const hashtag of this.hashtags) { let classname = this.getClassNameForHastag(hashtag); - let el = this.contentElement.nativeElement.querySelector(`.${classname}`); + let els = this.contentElement.nativeElement.querySelectorAll(`.${classname}`); - this.renderer.listen(el, 'click', (event) => { - event.preventDefault(); - event.stopImmediatePropagation(); + for (const el of els) { + this.renderer.listen(el, 'click', (event) => { + event.preventDefault(); + event.stopImmediatePropagation(); - this.selectHashtag(hashtag); - return false; - }); + this.selectHashtag(hashtag); + return false; + }); + } } for (const account of this.accounts) { let classname = this.getClassNameForAccount(account); - let el = this.contentElement.nativeElement.querySelector(`.${classname}`); + let els = this.contentElement.nativeElement.querySelectorAll(`.${classname}`); - this.renderer.listen(el, 'click', (event) => { - event.preventDefault(); - event.stopImmediatePropagation(); + for (const el of els) { + this.renderer.listen(el, 'click', (event) => { + event.preventDefault(); + event.stopImmediatePropagation(); - this.selectAccount(account); - return false; - }); + this.selectAccount(account); + return false; + }); + } } for (const link of this.links) { let classname = this.getClassNameForLink(link); - let el = this.contentElement.nativeElement.querySelector(`.${classname}`); - this.renderer.listen(el, 'click', (event) => { - event.preventDefault(); - event.stopImmediatePropagation(); + let els = this.contentElement.nativeElement.querySelectorAll(`.${classname}`); - window.open(link, '_blank'); - return false; - }); - - this.renderer.listen(el, 'mouseup', (event) => { - if (event.which === 2) { + for (const el of els) { + this.renderer.listen(el, 'click', (event) => { event.preventDefault(); event.stopImmediatePropagation(); window.open(link, '_blank'); return false; - } - }); + }); + + this.renderer.listen(el, 'mouseup', (event) => { + if (event.which === 2) { + event.preventDefault(); + event.stopImmediatePropagation(); + + window.open(link, '_blank'); + return false; + } + }); + } } }