From e229db7b17366b30fa2d158b056744d2b099bbae Mon Sep 17 00:00:00 2001 From: Keith Cirkel Date: Wed, 23 Nov 2022 18:19:54 +0000 Subject: [PATCH] fix typo in observed attributes --- src/relative-time-element.ts | 2 +- test/relative-time.js | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/relative-time-element.ts b/src/relative-time-element.ts index 0543181..298cb65 100644 --- a/src/relative-time-element.ts +++ b/src/relative-time-element.ts @@ -97,7 +97,7 @@ export default class RelativeTimeElement extends HTMLElement implements Intl.Dat 'year', 'time-zone-name', 'prefix', - 'threhsold', + 'threshold', 'tense', 'precision', 'format', diff --git a/test/relative-time.js b/test/relative-time.js index 2c42e50..79a8059 100644 --- a/test/relative-time.js +++ b/test/relative-time.js @@ -78,6 +78,19 @@ suite('relative-time', function () { assert.notEqual(nextDisplay, display) }) + test('all observedAttributes have getters', async function () { + const ALLOWED_PROPERTIES = ['time-zone-name'] + + const members = [ + ...Object.getOwnPropertyNames(RelativeTimeElement.prototype), + ...Object.getOwnPropertyNames(HTMLElement.prototype), + ...ALLOWED_PROPERTIES + ] + const observedAttributes = new Set(RelativeTimeElement.observedAttributes) + for (const member of members) observedAttributes.delete(member) + assert.empty([...observedAttributes], 'observedAttributes that arent class members') + }) + test("doesn't error when no date is provided", function () { const element = document.createElement('relative-time') assert.doesNotThrow(() => element.attributeChangedCallback('datetime', null, null))