Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override content for local-time and default formatting #97

Closed
Paxa opened this issue Aug 25, 2018 · 2 comments
Closed

Override content for local-time and default formatting #97

Paxa opened this issue Aug 25, 2018 · 2 comments

Comments

@Paxa
Copy link

Paxa commented Aug 25, 2018

I found 2 problems: appending content in chrome and no default formatting

No default formatting:

Source:

<local-time datetime="2018-08-24T16:57:42.604Z">Aug 24, 2018 23:57:42</local-time>

Result:

<local-time datetime="2018-08-24T16:57:42.604Z" title="Aug 24, 2018, 11:57 PM GMT+7">Aug 24, 2018 23:57:42</local-time>

would be much easier to start if it would apply default formatting month="short" day="numeric" year="numeric" hour="numeric" minute="numeric" (or similar) and may be update-content=false to prevent updating content

Appending content in chrome:
Source:

<local-time datetime="2014-04-01T16:30:00-08:00" month="short" day="numeric" year="numeric" hour="numeric" minute="numeric">April 1, 2014 4:30PM PDT</local-time>

Result:

<local-time datetime="2014-04-01T16:30:00-08:00" month="short" day="numeric" year="numeric" hour="numeric" minute="numeric" title="Apr 2, 2014, 7:30 AM GMT+7">Apr 2, 2014 7:30 AMApril 1, 2014 4:30PM PDT</local-time>
@betatim
Copy link

betatim commented Jul 2, 2021

I also have the "appending content" problem. But only if I use this library by import "@github/time-elements" in my bundle.js which webpack processes. If instead I add <script type="module" src="https://unpkg.com/@github/time-elements@3.1.2?module"></script> to my HTML file the problem doesn't appear (both when adding this script tag to <head> or just before the closing </body>).

What is weird is that all the steps I can step through with the debugger where something is assigned to this.textContent assign the correct thing. It is only when we return from https://github.com/github/time-elements/blob/40f3d1abb9a1271607182704fa949b5867f94496/src/local-time-element.ts#L133 (or that is how it looks in the debugger) that the old text content of the tag is added in again.

I think my webpack setup is fairly pedestrian. One thing to note is that I don't have a polyfill installed but I think that is Ok because my browser is Firefox 90.0b10 (64-bit).

The bundle is about 100kB and loaded via <script src="dist/bundle.js"></script> in the <head>.

Somehow this feels like there is a race between two things or me not correctly initialising the time-elements library :-/

@keithamus
Copy link
Member

If you'd like to try the new release I believe this issue is likely fixed. If not let me know and we can revisit it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants