From 257f0eb99b5b7a805ada1f2c84ffc01e87e7d4a2 Mon Sep 17 00:00:00 2001 From: Clay Miller Date: Fri, 31 May 2024 18:19:08 +0000 Subject: [PATCH] fix: Move 'noTitle' conditional. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Calculate the new title, just don’t update the attribute. This change means the 'relative-time-updated' event will fire even if 'noTitle' is set. --- src/relative-time-element.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/relative-time-element.ts b/src/relative-time-element.ts index c844a9d..660b169 100644 --- a/src/relative-time-element.ts +++ b/src/relative-time-element.ts @@ -440,9 +440,9 @@ export class RelativeTimeElement extends HTMLElement implements Intl.DateTimeFor return } const now = Date.now() - if (!this.#customTitle && !this.noTitle) { + if (!this.#customTitle) { newTitle = this.#getFormattedTitle(date) || '' - if (newTitle) this.setAttribute('title', newTitle) + if (newTitle && !this.noTitle) this.setAttribute('title', newTitle) } const duration = elapsedTime(date, this.precision, now)