You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
<!DOCTYPE html><shadowed-element><templateshadowroot=open><!-- This is the SSR content --><style>div {
font-size:24pt;
color: blue;
}
</style><div><spanid=hour>12</span> : <spanid=min>34</span> : <spanid=sec>56</span></div></template></shadowed-element><script>customElements.define('shadowed-element',classextendsHTMLElement{constructor(){super();letshadowRoot=null;try{constinternals=this.attachInternals();if(internals.shadowRoot){shadowRoot=internals.shadowRoot;}}catch(e){}if(!shadowRoot){vartemplate=this.querySelector('template');shadowRoot=this.attachShadow({mode: 'open'});shadowRoot.innerHTML=template.innerHTML;}this.hours=shadowRoot.querySelector('#hour');this.minutes=shadowRoot.querySelector('#min');this.seconds=shadowRoot.querySelector('#sec');}connectedCallback(){this.update();this.interval=setInterval(()=>this.update(),1000);}disconnectedCallback(){clearInterval(this.interval);}update(){constpad=v=>{returnString(v).padStart(2,'0')}constd=newDate();this.hours.textContent=pad(d.getHours());this.minutes.textContent=pad(d.getMinutes());this.seconds.textContent=pad(d.getSeconds());}});</script>
That way the data does not need to be duplicated.
Live example here:
https://jsbin.com/joyavociza/edit?html,output
The text was updated successfully, but these errors were encountered: