<custom-element>
<template>
<local-storage key="dateKey" slice="date-key" type="date" live="live"></local-storage>
<local-storage key="timeKey" slice="time-key" type="time" live="live"></local-storage>
<local-storage key="localDateTimeKey" slice="local-date-time" type="datetime-local" live="live"></local-storage>
<local-storage key="numberKey" slice="number-key" type="number" live="live"></local-storage>
<local-storage key="jsonKey" slice="json-key" type="json" live="live"></local-storage>
<input id="typesinput" placeholder="set value"><button onclick="
'dateKey,timeKey,localDateTimeKey,numberKey,jsonKey'.split(',')
.map( k=> localStorage.setItem(k, typesinput.value) )
"> set to all</button><br>
<hr>
date-key:
<button onclick="localStorage.setItem('dateKey', '2024-04-20T03:58:42.131Z')">2024-04-21T03:58:42.131Z </button>
<button onclick="localStorage.setItem('dateKey', new Date(Date.now()).toISOString())">now </button>
<button onclick="localStorage.setItem('dateKey', 'ABC' )">date ABC - invalid </button>
<code>{//date-key }</code><br>
time-key:
<button onclick="localStorage.setItem('timeKey', '13:30')">13:30 </button>
<code>{//time-key }</code><br>
local-date-time:
<button onclick="localStorage.setItem('localDateTimeKey', '1977-04-01T14:00:30')">21977-04-01T14:00:30 - local </button>
<code>{//local-date-time}</code><br>
number-key:
<button onclick="localStorage.setItem('numberKey', '2024' )">2024 - number </button>
<button onclick="localStorage.setItem('numberKey', '24' )">24 - number </button>
<button onclick="localStorage.setItem('numberKey', '1.23456e+5' )">1.23456e+5 </button>
<button onclick="localStorage.setItem('numberKey', '0001' )">0001 </button>
<button onclick="localStorage.setItem('numberKey', '000' )">000 </button>
<button onclick="localStorage.setItem('numberKey', '0' )">0 </button>
<button onclick="localStorage.setItem('numberKey', 'ABC' )">ABC - invalid, NaN </button>
<code>{//number-key }</code> <br>
<fieldset>
<legend>json-key: </legend>
<button onclick="localStorage.setItem('jsonKey', JSON.stringify('ABC'))">'ABC' - string </button>
<button onclick="localStorage.setItem('jsonKey', JSON.stringify(12.345))">12.345 - number </button>
<button onclick="localStorage.setItem('jsonKey', JSON.stringify(window.JsonSample) )">a:1,b:'B' -json </button>
<button onclick="localStorage.setItem('jsonKey', 'ABC' )">ABC - invalid </button><br>
json-key:<code><xsl:apply-templates select="//json-key/value/@*|//json-key/text()|//json-key/value/text()" mode="json"></xsl:apply-templates></code>
</fieldset>
<xsl:template mode="json" match="*|@*">
<div>{name()} : {.}</div>
</xsl:template>
</template>
</custom-element>