FIX: Do not track a elements with no href.

FIX: Do not track a elements with no href.

diff --git a/app/assets/javascripts/discourse/lib/click-track.js.es6 b/app/assets/javascripts/discourse/lib/click-track.js.es6
index 1143275..52b1b78 100644
--- a/app/assets/javascripts/discourse/lib/click-track.js.es6
+++ b/app/assets/javascripts/discourse/lib/click-track.js.es6
@@ -10,7 +10,11 @@ export function isValidLink($link) {
   //  - links with disabled tracking
   //  - category links
   //  - quote back button
-  if ($link.is(".lightbox, .mention, .mention-group, .no-track-link, .hashtag, .back")) {
+  if (
+    $link.is(
+      ".lightbox, .mention, .mention-group, .no-track-link, .hashtag, .back"
+    )
+  ) {
     return false;
   }
 
@@ -63,10 +67,8 @@ export default {
       return true;
     }
 
-    let href = ($link.attr("href") || $link.data("href")).trim();
-    if (!href) {
-      return false;
-    } else if (href.indexOf("mailto:") === 0) {
+    let href = ($link.attr("href") || $link.data("href") || "").trim();
+    if (!href || href.indexOf("mailto:") === 0) {
       return true;
     }

GitHub sha: b9339e15

How often do we end up with <a> elements with no href?

It’s more common than I thought. It usually happens when there is an action such as <a {{action....

In that case, we also need a test :wink:

DEV: Add test for click-track and <a> without href.