From d08936f47642e123a10927e5f22d486b2cef6dc1 Mon Sep 17 00:00:00 2001 From: silverpill Date: Sat, 11 Dec 2021 22:54:08 +0000 Subject: [PATCH] Add target=_blank and rel=noreferrer to mentions --- src/components/Post.vue | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/components/Post.vue b/src/components/Post.vue index b0b725e..baea35a 100644 --- a/src/components/Post.vue +++ b/src/components/Post.vue @@ -41,7 +41,7 @@ {{ formatDate(post.created_at) }} -
+
@@ -228,6 +228,16 @@ export default class PostComponent extends Vue { return { currentUser, ensureAuthToken, instance } }) + $refs!: { postContent: HTMLElement } + + mounted() { + const mentions = this.$refs.postContent.getElementsByClassName("mention") + for (const mention of Array.from(mentions)) { + mention.setAttribute("target", "_blank") + mention.setAttribute("rel", "noreferrer") + } + } + get authorName(): string { return this.post.account.display_name || this.post.account.username }