Skip to content

A platform for community discussion. Free, open, simple.

DEV: Convert HtmlWithLinks to glimmer/gjs (#37389)

Jarek Radosz0c1a658f28c2
diff --git a/frontend/discourse/app/components/html-with-links.gjs b/frontend/discourse/app/components/html-with-links.gjs
new file mode 100644
index 00000000000..1b7fe6e0a56
--- /dev/null
+++ b/frontend/discourse/app/components/html-with-links.gjs
@@ -0,0 +1,23 @@
+import Component from "@glimmer/component";
+import { on } from "@ember/modifier";
+import { action } from "@ember/object";
+import {
+ openLinkInNewTab,
+ shouldOpenInNewTab,
+} from "discourse/lib/click-track";
+
+export default class HtmlWithLinks extends Component {
+ @action
+ click(event) {
+ if (event.target.tagName === "A") {
+ if (shouldOpenInNewTab(event.target.href)) {
+ openLinkInNewTab(event, event.target);
+ }
+ }
+ }
+
+ <template>
+ {{! template-lint-disable no-invalid-interactive }}
+ <div {{on "click" this.click}} ...attributes>{{yield}}</div>
+ </template>
+}
diff --git a/frontend/discourse/app/components/html-with-links.js b/frontend/discourse/app/components/html-with-links.js
deleted file mode 100644
index 774be6d7ddd..00000000000
--- a/frontend/discourse/app/components/html-with-links.js
+++ /dev/null
@@ -1,16 +0,0 @@
-/* eslint-disable ember/no-classic-components */
-import Component from "@ember/component";
-import {
- openLinkInNewTab,
- shouldOpenInNewTab,
-} from "discourse/lib/click-track";
-
-export default class HtmlWithLinks extends Component {
- click(event) {
- if (event?.target?.tagName === "A") {
- if (shouldOpenInNewTab(event.target.href)) {
- openLinkInNewTab(event, event.target);
- }
- }
- }
-}