Override content for local-time and default formatting
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>
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/[email protected]?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 :-/
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.