-
Notifications
You must be signed in to change notification settings - Fork 175
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #210 from github/add-define-export-for-custom-elem…
…ent-registration add `define` export for custom element registration
- Loading branch information
Showing
6 changed files
with
120 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,50 +1,6 @@ | ||
import LocalTimeElement from './local-time-element.js' | ||
import RelativeTimeElement from './relative-time-element.js' | ||
import TimeAgoElement from './time-ago-element.js' | ||
import TimeUntilElement from './time-until-element.js' | ||
|
||
const root = (typeof globalThis !== 'undefined' ? globalThis : window) as typeof window | ||
try { | ||
customElements.define('relative-time', RelativeTimeElement) | ||
root.RelativeTimeElement = RelativeTimeElement | ||
} catch (e: unknown) { | ||
if (!(e instanceof DOMException && e.name === 'NotSupportedError') && !(e instanceof ReferenceError)) throw e | ||
} | ||
|
||
try { | ||
customElements.define('local-time', LocalTimeElement) | ||
root.LocalTimeElement = LocalTimeElement | ||
} catch (e: unknown) { | ||
if (!(e instanceof DOMException && e.name === 'NotSupportedError') && !(e instanceof ReferenceError)) throw e | ||
} | ||
|
||
try { | ||
customElements.define('time-ago', TimeAgoElement) | ||
root.TimeAgoElement = TimeAgoElement | ||
} catch (e: unknown) { | ||
if (!(e instanceof DOMException && e.name === 'NotSupportedError') && !(e instanceof ReferenceError)) throw e | ||
} | ||
|
||
try { | ||
customElements.define('time-until', TimeUntilElement) | ||
root.TimeUntilElement = TimeUntilElement | ||
} catch (e: unknown) { | ||
if (!(e instanceof DOMException && e.name === 'NotSupportedError') && !(e instanceof ReferenceError)) throw e | ||
} | ||
|
||
declare global { | ||
interface Window { | ||
RelativeTimeElement: typeof RelativeTimeElement | ||
LocalTimeElement: typeof LocalTimeElement | ||
TimeAgoElement: typeof TimeAgoElement | ||
TimeUntilElement: typeof TimeUntilElement | ||
} | ||
interface HTMLElementTagNameMap { | ||
'relative-time': RelativeTimeElement | ||
'local-time': LocalTimeElement | ||
'time-ago': TimeAgoElement | ||
'time-until': TimeUntilElement | ||
} | ||
} | ||
import LocalTimeElement from './local-time-element-define.js' | ||
import RelativeTimeElement from './relative-time-element-define.js' | ||
import TimeAgoElement from './time-ago-element-define.js' | ||
import TimeUntilElement from './time-until-element-define.js' | ||
|
||
export {LocalTimeElement, RelativeTimeElement, TimeAgoElement, TimeUntilElement} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import LocalTimeElement from './local-time-element.js' | ||
|
||
const root = (typeof globalThis !== 'undefined' ? globalThis : window) as typeof window | ||
try { | ||
customElements.define('local-time', LocalTimeElement) | ||
root.LocalTimeElement = LocalTimeElement | ||
} catch (e: unknown) { | ||
if ( | ||
!(root.DOMException && e instanceof DOMException && e.name === 'NotSupportedError') && | ||
!(e instanceof ReferenceError) | ||
) { | ||
throw e | ||
} | ||
} | ||
|
||
declare global { | ||
interface Window { | ||
LocalTimeElement: typeof LocalTimeElement | ||
} | ||
interface HTMLElementTagNameMap { | ||
'local-time': LocalTimeElement | ||
} | ||
} | ||
|
||
export default LocalTimeElement | ||
export * from './local-time-element.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import RelativeTimeElement from './relative-time-element.js' | ||
|
||
const root = (typeof globalThis !== 'undefined' ? globalThis : window) as typeof window | ||
try { | ||
customElements.define('relative-time', RelativeTimeElement) | ||
root.RelativeTimeElement = RelativeTimeElement | ||
} catch (e: unknown) { | ||
if ( | ||
!(root.DOMException && e instanceof DOMException && e.name === 'NotSupportedError') && | ||
!(e instanceof ReferenceError) | ||
) { | ||
throw e | ||
} | ||
} | ||
|
||
declare global { | ||
interface Window { | ||
RelativeTimeElement: typeof RelativeTimeElement | ||
} | ||
interface HTMLElementTagNameMap { | ||
'relative-time': RelativeTimeElement | ||
} | ||
} | ||
|
||
export default RelativeTimeElement | ||
export * from './relative-time-element.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import TimeAgoElement from './time-ago-element.js' | ||
|
||
const root = (typeof globalThis !== 'undefined' ? globalThis : window) as typeof window | ||
try { | ||
customElements.define('time-ago', TimeAgoElement) | ||
root.TimeAgoElement = TimeAgoElement | ||
} catch (e: unknown) { | ||
if ( | ||
!(root.DOMException && e instanceof DOMException && e.name === 'NotSupportedError') && | ||
!(e instanceof ReferenceError) | ||
) { | ||
throw e | ||
} | ||
} | ||
|
||
declare global { | ||
interface Window { | ||
TimeAgoElement: typeof TimeAgoElement | ||
} | ||
interface HTMLElementTagNameMap { | ||
'time-ago': TimeAgoElement | ||
} | ||
} | ||
|
||
export default TimeAgoElement | ||
export * from './time-ago-element.js' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import TimeUntilElement from './time-until-element.js' | ||
|
||
const root = (typeof globalThis !== 'undefined' ? globalThis : window) as typeof window | ||
try { | ||
customElements.define('time-until', TimeUntilElement) | ||
root.TimeUntilElement = TimeUntilElement | ||
} catch (e: unknown) { | ||
if ( | ||
!(root.DOMException && e instanceof DOMException && e.name === 'NotSupportedError') && | ||
!(e instanceof ReferenceError) | ||
) { | ||
throw e | ||
} | ||
} | ||
|
||
declare global { | ||
interface Window { | ||
TimeUntilElement: typeof TimeUntilElement | ||
} | ||
interface HTMLElementTagNameMap { | ||
'time-until': TimeUntilElement | ||
} | ||
} | ||
|
||
export default TimeUntilElement | ||
export * from './time-until-element.js' |