@epa-wg/custom-element 0.0.26 → 0.0.27
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -3
- package/bin/xslDtd2Ide.mjs +1 -1
- package/custom-element.js +67 -14
- package/demo/a.svg +27 -0
- package/demo/demo.css +6 -7
- package/demo/external-template.html +3 -3
- package/demo/npm-versions-demo.html +21 -8
- package/demo/npm-versions.html +54 -25
- package/demo/s.xml +3 -28
- package/demo/s.xslt +51 -92
- package/demo/z.html +32 -61
- package/demo/z1.html +34 -0
- package/ide/web-types-dce.json +1 -1
- package/ide/web-types-xsl.json +1 -1
- package/index.html +19 -2
- package/local-storage.js +19 -14
- package/module-url.js +3 -2
- package/package.json +1 -1
- package/request.html +0 -53
package/README.md
CHANGED
|
@@ -348,9 +348,9 @@ within template
|
|
|
348
348
|
[github-image]: https://cdnjs.cloudflare.com/ajax/libs/octicons/8.5.0/svg/mark-github.svg
|
|
349
349
|
[npm-image]: https://img.shields.io/npm/v/@epa-wg/custom-element.svg
|
|
350
350
|
[npm-url]: https://npmjs.org/package/@epa-wg/custom-element
|
|
351
|
-
[coverage-image]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.
|
|
352
|
-
[coverage-url]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.
|
|
353
|
-
[storybook-url]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.
|
|
351
|
+
[coverage-image]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.27/coverage/src/custom-element/coverage.svg
|
|
352
|
+
[coverage-url]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.27/coverage/src/custom-element/index.html
|
|
353
|
+
[storybook-url]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.27/storybook-static/index.html?path=/story/welcome--introduction
|
|
354
354
|
[sandbox-url]: https://stackblitz.com/github/EPA-WG/custom-element?file=index.html
|
|
355
355
|
[webcomponents-url]: https://www.webcomponents.org/element/@epa-wg/custom-element
|
|
356
356
|
[webcomponents-img]: https://img.shields.io/badge/webcomponents.org-published-blue.svg
|
package/bin/xslDtd2Ide.mjs
CHANGED
|
@@ -116,7 +116,7 @@ writeFileSync( '.././ide/customData-xsl.json', JSON.stringify( vsCode, undefined
|
|
|
116
116
|
const intelliJ = {
|
|
117
117
|
"$schema": "http://json.schemastore.org/web-types",
|
|
118
118
|
"name": "@epa-wg/custom-element",
|
|
119
|
-
"version": "0.0.
|
|
119
|
+
"version": "0.0.27",
|
|
120
120
|
"js-types-syntax": "typescript",
|
|
121
121
|
"description-markup": "markdown",
|
|
122
122
|
"contributions": {
|
package/custom-element.js
CHANGED
|
@@ -47,6 +47,7 @@ xml2dom( xmlString )
|
|
|
47
47
|
}
|
|
48
48
|
export function
|
|
49
49
|
xmlString(doc){ return new XMLSerializer().serializeToString( doc ) }
|
|
50
|
+
function x(doc) { return xmlString(doc) }
|
|
50
51
|
|
|
51
52
|
function
|
|
52
53
|
injectData( root, sectionName, arr, cb )
|
|
@@ -145,22 +146,63 @@ createXsltFromDom( templateNode, S = 'xsl:stylesheet' )
|
|
|
145
146
|
if( templateNode.tagName === S || templateNode.documentElement?.tagName === S )
|
|
146
147
|
return tagUid(templateNode)
|
|
147
148
|
const sanitizeXsl = xml2dom(`<xsl:stylesheet version="1.0" xmlns:xsl="${ XSL_NS_URL }" xmlns:xhtml="${ HTML_NS_URL }" xmlns:exsl="${EXSL_NS_URL}" exclude-result-prefixes="exsl" >
|
|
148
|
-
|
|
149
|
-
<xsl:template match="/"><dce-root xmlns="${ HTML_NS_URL }"><xsl:apply-templates select="*"/></dce-root></xsl:template>
|
|
150
|
-
|
|
151
|
-
<xsl:
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
<xsl:
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
<xsl:
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
149
|
+
<xsl:output method="xml"/>
|
|
150
|
+
<xsl:template match="/"><dce-root xmlns="${ HTML_NS_URL }"><xsl:apply-templates select="*" /></dce-root></xsl:template>
|
|
151
|
+
<xsl:template match="*[name()='template']">
|
|
152
|
+
<xsl:apply-templates mode="sanitize" select="*|text()"/>
|
|
153
|
+
</xsl:template>
|
|
154
|
+
<xsl:template match="*">
|
|
155
|
+
<xsl:apply-templates mode="sanitize" select="*|text()"/>
|
|
156
|
+
</xsl:template>
|
|
157
|
+
<xsl:template match="*[name()='svg']|*[name()='math']">
|
|
158
|
+
<xsl:apply-templates mode="sanitize" select="."/>
|
|
159
|
+
</xsl:template>
|
|
160
|
+
<xsl:template mode="sanitize" match="*[count(text())=1 and count(*)=0]">
|
|
161
|
+
<xsl:copy>
|
|
162
|
+
<xsl:apply-templates mode="sanitize" select="@*"/>
|
|
163
|
+
<xsl:value-of select="text()"></xsl:value-of>
|
|
164
|
+
</xsl:copy>
|
|
165
|
+
</xsl:template>
|
|
166
|
+
<xsl:template mode="sanitize" match="xhtml:*[count(text())=1 and count(*)=0]">
|
|
167
|
+
<xsl:element name="{local-name()}">
|
|
168
|
+
<xsl:apply-templates mode="sanitize" select="@*"/>
|
|
169
|
+
<xsl:value-of select="text()"></xsl:value-of>
|
|
170
|
+
</xsl:element>
|
|
171
|
+
</xsl:template>
|
|
172
|
+
<xsl:template mode="sanitize" match="*|@*">
|
|
173
|
+
<xsl:copy>
|
|
174
|
+
<xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
|
|
175
|
+
</xsl:copy>
|
|
176
|
+
</xsl:template>
|
|
177
|
+
<xsl:template mode="sanitize" match="text()[normalize-space(.) = '']"/>
|
|
178
|
+
<xsl:template mode="sanitize" match="text()">
|
|
179
|
+
<dce-text>
|
|
180
|
+
<xsl:copy/>
|
|
181
|
+
</dce-text>
|
|
182
|
+
</xsl:template>
|
|
183
|
+
<xsl:template mode="sanitize" match="xsl:value-of|*[name()='slot']">
|
|
184
|
+
<dce-text>
|
|
185
|
+
<xsl:copy>
|
|
186
|
+
<xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
|
|
187
|
+
</xsl:copy>
|
|
188
|
+
</dce-text>
|
|
189
|
+
</xsl:template>
|
|
190
|
+
<xsl:template mode="sanitize" match="xhtml:*">
|
|
191
|
+
<xsl:element name="{local-name()}">
|
|
192
|
+
<xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
|
|
193
|
+
</xsl:element>
|
|
194
|
+
</xsl:template>
|
|
195
|
+
</xsl:stylesheet>`)
|
|
161
196
|
const sanitizeProcessor = new XSLTProcessor()
|
|
162
197
|
, tc = (n =>
|
|
163
198
|
{
|
|
199
|
+
forEach$(n,'custom-element', ce=>{
|
|
200
|
+
if( 'template' === ce.firstElementChild.localName )
|
|
201
|
+
{
|
|
202
|
+
[...ce.firstElementChild.content.childNodes].forEach(n=>ce.append(n));
|
|
203
|
+
ce.firstElementChild.remove();
|
|
204
|
+
}
|
|
205
|
+
})
|
|
164
206
|
forEach$(n,'script', s=> s.remove() );
|
|
165
207
|
const xslRoot = n.content ?? n.firstElementChild?.content ?? n.body ?? n;
|
|
166
208
|
xslTags.forEach( tag => forEach$( xslRoot, tag, el=>toXsl(el,xslRoot) ) );
|
|
@@ -223,6 +265,11 @@ createXsltFromDom( templateNode, S = 'xsl:stylesheet' )
|
|
|
223
265
|
, payload = $( xslDom, 'template[mode="payload"]');
|
|
224
266
|
if( !fr )
|
|
225
267
|
return console.error("transformation error",{ xml:tc.outerHTML, xsl: xmlString( sanitizeXsl ) });
|
|
268
|
+
if( 'dce-root'!==fr.firstElementChild.localName )
|
|
269
|
+
{ const r = fr.ownerDocument.createElement('dce-root');
|
|
270
|
+
[...fr.childNodes].forEach(n=>r.append(n));
|
|
271
|
+
fr.append(r)
|
|
272
|
+
}
|
|
226
273
|
const params = [];
|
|
227
274
|
[...fr.querySelectorAll('dce-root>attribute')].forEach( a=>
|
|
228
275
|
{
|
|
@@ -574,7 +621,13 @@ CustomElement extends HTMLElement
|
|
|
574
621
|
this.append(s);
|
|
575
622
|
})
|
|
576
623
|
const templateDocs = templateRoots.map( n => createXsltFromDom( n ) )
|
|
577
|
-
, xp = templateDocs.map( (td, p) =>
|
|
624
|
+
, xp = templateDocs.map( (td, p) =>
|
|
625
|
+
{ p = new XSLTProcessor();
|
|
626
|
+
try{ p.importStylesheet( td ) }
|
|
627
|
+
catch( e )
|
|
628
|
+
{ console.error(e, xmlString(td)) }
|
|
629
|
+
return p
|
|
630
|
+
})
|
|
578
631
|
|
|
579
632
|
Object.defineProperty( this, "xsltString", { get: ()=>templateDocs.map( td => xmlString(td) ).join('\n') });
|
|
580
633
|
|
package/demo/a.svg
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
<svg id="dwc-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 216 209.18" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
|
2
|
+
<defs>
|
|
3
|
+
|
|
4
|
+
</defs>
|
|
5
|
+
<polygon class="cls-3" points="0 82.47 0 126.71 34.84 146.83 34.84 187.06 73.16 209.18 108 189.07 142.84 209.18 181.16 187.06 181.16 146.83 216 126.71 216 82.47 181.16 62.35 181.16 22.12 142.84 0 108 20.12 73.16 0 34.84 22.12 34.84 62.35 0 82.47"/>
|
|
6
|
+
<path class="cls-2" d="m114.33,56.69l20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0Z"/>
|
|
7
|
+
<path class="cls-2" d="m98.19,62.71h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
8
|
+
<path class="cls-1" d="m48.12,66.01l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97Z"/>
|
|
9
|
+
<path class="cls-2" d="m46.18,24.66l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0s20.64-11.92,20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06Z"/>
|
|
10
|
+
<path class="cls-2" d="m115.87,24.66l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0s20.64-11.92,20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06Z"/>
|
|
11
|
+
<path class="cls-2" d="m152.65,42.59c-4.44,2.56-6.33,5.84-6.33,10.97v23.84c0,.54.45.8.92.54l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0v-23.84c0-.54-.45-.8-.92-.53l-20.64,11.92h0Z"/>
|
|
12
|
+
<path class="cls-2" d="m77.55,158.4l20.65-11.92h0c4.44-2.57,6.33-5.84,6.33-10.97v-23.84c0-.54-.45-.8-.92-.53l-20.64,11.92c-4.44,2.57-6.33,5.84-6.33,10.97h0s0,23.84,0,23.84c0,.54.45.8.92.54Z"/>
|
|
13
|
+
<path class="cls-4" d="m146.31,134.03v23.84c0,.54.45.8.92.54l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0s0-23.84,0-23.84c0-.54-.45-.8-.92-.53l-20.64,11.92h0c-4.44,2.57-6.33,5.84-6.33,10.97Z"/>
|
|
14
|
+
<path class="cls-4" d="m63.35,123.06h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
15
|
+
<path class="cls-4" d="m103.61,151.37l-20.64,11.92c-4.44,2.57-6.33,5.84-6.33,10.97h0s0,23.84,0,23.84c0,.54.45.8.92.54l20.65-11.92h0c4.44-2.57,6.33-5.84,6.33-10.97v-23.84c0-.54-.45-.8-.92-.53Z"/>
|
|
16
|
+
<path class="cls-4" d="m63.35,163.29h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
17
|
+
<path class="cls-4" d="m28.51,102.94h0s-20.64-11.92-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84s0,0,0,0c0,5.13,1.89,8.4,6.33,10.97l20.65,11.92c.47.27.92,0,.92-.54v-23.84c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
18
|
+
<path class="cls-4" d="m133.04,163.29l-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84c0,5.13,1.89,8.4,6.33,10.97h0s20.65,11.92,20.65,11.92c.47.27.92,0,.92-.54v-23.84s0,0,0,0c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
19
|
+
<path class="cls-4" d="m173.29,151.37l-20.64,11.92h0c-4.44,2.57-6.33,5.84-6.33,10.97v23.84c0,.54.45.8.92.54l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0s0-23.84,0-23.84c0-.54-.45-.8-.92-.53Z"/>
|
|
20
|
+
<path class="cls-4" d="m209.06,91.55c0-.54-.45-.8-.92-.53l-20.64,11.92h0c-4.44,2.57-6.33,5.84-6.33,10.97v23.84c0,.54.45.8.92.54l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0v-23.84Z"/>
|
|
21
|
+
<path class="cls-2" d="m149.18,117.04l20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0Z"/>
|
|
22
|
+
<path class="cls-1" d="m112.39,98.05l20.65-11.92c4.44-2.57,6.33-5.84,6.33-10.97h0v-23.84c0-.54-.45-.8-.92-.53l-20.64,11.92h0c-4.44,2.57-6.33,5.84-6.33,10.97v23.84c0,.54.45.8.92.54Z"/>
|
|
23
|
+
<path class="cls-1" d="m100.13,105.12c.47-.27.47-.79,0-1.06l-20.65-11.92c-4.44-2.57-8.22-2.57-12.67,0h0s-20.65,11.92-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92h0c4.44,2.57,8.22,2.57,12.67,0l20.64-11.92Z"/>
|
|
24
|
+
<path class="cls-2" d="m65.29,85.01c.47-.27.47-.79,0-1.06l-20.65-11.92c-4.44-2.57-8.22-2.57-12.67,0h0s-20.65,11.92-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92h0c4.44,2.57,8.22,2.57,12.67,0l20.64-11.92Z"/>
|
|
25
|
+
<path class="cls-1" d="m133.04,123.06l-20.64-11.92c-.47-.27-.92-.01-.92.53v23.84c0,5.13,1.89,8.4,6.33,10.97h0s20.65,11.92,20.65,11.92c.47.27.92,0,.92-.54v-23.84s0,0,0,0c0-5.13-1.89-8.4-6.33-10.97Z"/>
|
|
26
|
+
<path class="cls-1" d="m184.02,96.93l20.64-11.92c.47-.27.47-.79,0-1.06l-20.65-11.92h0c-4.44-2.57-8.22-2.57-12.67,0l-20.65,11.92c-.47.27-.47.79,0,1.06l20.64,11.92c4.44,2.57,8.22,2.57,12.67,0h0Z"/>
|
|
27
|
+
</svg>
|
package/demo/demo.css
CHANGED
|
@@ -4,13 +4,12 @@ html
|
|
|
4
4
|
}
|
|
5
5
|
body,nav{ display: flex; flex-wrap: wrap; align-content: stretch; gap: 1rem; }
|
|
6
6
|
body>*{flex: auto;}
|
|
7
|
-
nav
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
{ box-shadow: 0 0 0.5rem lime; padding: 1rem; display: inline-block; flex:1; }
|
|
7
|
+
nav
|
|
8
|
+
{ flex-direction: column;
|
|
9
|
+
dce-root{ box-shadow:none; padding: 0;}
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
html-demo-element *:has(>dce-root){ box-shadow: 0 0 0.5rem lime; padding: 1rem; flex:1; display: block; }
|
|
14
13
|
script{ display:none !important; }
|
|
15
14
|
dd{ padding: 1rem;}
|
|
16
15
|
p{ margin: 0;}
|
|
@@ -141,13 +141,13 @@
|
|
|
141
141
|
<html-demo-element legend="6. HTML, SVG by ID within external file" description="Should render 👋, svg, formula">
|
|
142
142
|
<a href="html-template.html">html-template.html</a>
|
|
143
143
|
<template>
|
|
144
|
-
<custom-element src="html-template.html#wave">
|
|
144
|
+
<custom-element src="./html-template.html#wave">
|
|
145
145
|
<template><i>loading HTML from templates file ...</i></template>
|
|
146
146
|
</custom-element>
|
|
147
|
-
<custom-element src="html-template.html#dwc-logo">
|
|
147
|
+
<custom-element src="./html-template.html#dwc-logo">
|
|
148
148
|
<template><i>loading SVG from templates file ...</i></template>
|
|
149
149
|
</custom-element>
|
|
150
|
-
<custom-element src="html-template.html#sophomores-dream">
|
|
150
|
+
<custom-element src="./html-template.html#sophomores-dream">
|
|
151
151
|
<template><i>loading MathML from HTML file ...</i></template>
|
|
152
152
|
</custom-element>
|
|
153
153
|
</template>
|
|
@@ -4,8 +4,16 @@
|
|
|
4
4
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
5
5
|
<title>DOM merge - Declarative Custom Element implementation demo</title>
|
|
6
6
|
<link rel="icon" href="./wc-square.svg"/>
|
|
7
|
-
|
|
7
|
+
<script type="importmap">
|
|
8
|
+
{
|
|
9
|
+
"imports": {
|
|
10
|
+
"@epa-wg/custom-element/": "../",
|
|
11
|
+
"@epa-wg/custom-element-dist/": "../"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
</script>
|
|
8
15
|
<script type="module" src="../http-request.js"></script>
|
|
16
|
+
<script type="module" src="../location-element.js"></script>
|
|
9
17
|
<script type="module" src="../custom-element.js"></script>
|
|
10
18
|
<style>
|
|
11
19
|
@import "./demo.css";
|
|
@@ -40,16 +48,20 @@
|
|
|
40
48
|
<html-demo-element legend="1. NPM package version picker"
|
|
41
49
|
description="defaults, last version should be preselected">
|
|
42
50
|
<template>
|
|
43
|
-
<custom-element
|
|
44
|
-
|
|
51
|
+
<custom-element src="./npm-versions.html#npm-version"
|
|
52
|
+
package-name="@epa-wg/custom-element-dist"></custom-element>
|
|
45
53
|
</template>
|
|
46
54
|
</html-demo-element>
|
|
47
55
|
|
|
48
56
|
<html-demo-element legend="2. preselected NPM package version picker"
|
|
49
|
-
description="version 22 should be selected">
|
|
57
|
+
description="version 22 should be selected and date shown">
|
|
50
58
|
<template>
|
|
51
59
|
<custom-element tag="custom-element-version" src="./npm-versions.html#npm-version"></custom-element>
|
|
52
|
-
<custom-element-version
|
|
60
|
+
<custom-element-version
|
|
61
|
+
package-name="@epa-wg/custom-element"
|
|
62
|
+
current-version="0.0.22"
|
|
63
|
+
show-date="true"
|
|
64
|
+
></custom-element-version>
|
|
53
65
|
</template>
|
|
54
66
|
</html-demo-element>
|
|
55
67
|
|
|
@@ -90,11 +102,12 @@
|
|
|
90
102
|
|
|
91
103
|
<html-demo-element legend="5. control version in URL"
|
|
92
104
|
description="">
|
|
93
|
-
1. <button onclick="window.location.hash = `#@epa-wg/custom-element-dist@0.0.
|
|
94
|
-
(can be skipped when run from unpkg.com)<br/>
|
|
105
|
+
1. <button onclick="window.location.hash = `#@epa-wg/custom-element-dist@0.0.25/storybook-static/index.html`">set in page URL to version 0.0.25</button><br/>
|
|
95
106
|
2. switch the package version in select and observe the URL change.
|
|
96
107
|
<template>
|
|
97
|
-
<custom-element src="
|
|
108
|
+
<custom-element src="@epa-wg/custom-element-dist/demo/npm-versions.html#npm-version-to-url"
|
|
109
|
+
package-name="@epa-wg/custom-element-dist"
|
|
110
|
+
></custom-element>
|
|
98
111
|
</template>
|
|
99
112
|
</html-demo-element>
|
|
100
113
|
|
package/demo/npm-versions.html
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
5
5
|
<title>npm-version template</title>
|
|
6
6
|
<link rel="icon" href="./wc-square.svg"/>
|
|
7
|
+
|
|
7
8
|
</head>
|
|
8
9
|
<body>
|
|
9
10
|
|
|
@@ -11,28 +12,29 @@
|
|
|
11
12
|
<a href="./npm-versions-demo.html">docs</a>
|
|
12
13
|
<template id="npm-version">
|
|
13
14
|
<attribute name="package-name"></attribute>
|
|
14
|
-
<attribute name="current-version"></attribute>
|
|
15
|
+
<attribute name="current-version" aria-description="version to select"></attribute>
|
|
16
|
+
<attribute name="show-date" aria-description="set to 'true' to append the date to the version"></attribute>
|
|
15
17
|
<attribute name="value" select="//selected-version"></attribute>
|
|
16
|
-
|
|
17
18
|
<http-request
|
|
18
|
-
url="https://registry.npmjs.org
|
|
19
|
+
url="https://registry.npmjs.org/{$package-name}"
|
|
19
20
|
method="GET"
|
|
20
21
|
header-accept="application/json"
|
|
21
22
|
slice="versions-ajax"></http-request>
|
|
22
23
|
|
|
23
|
-
<label
|
|
24
|
+
<label>
|
|
25
|
+
<slot name="label"><var>{$package-name}</var> version:</slot>
|
|
24
26
|
<xhtml:select slice="selected-version" autocomplete="off" name="version">
|
|
25
27
|
<for-each select="//versions/*">
|
|
26
28
|
<option value="{./@version}">
|
|
27
29
|
<variable name="item-version">{./@version}</variable>
|
|
28
|
-
{ $item-version } - { substring( //time/*[@dce-object-name = $item-version ], 1,10)}
|
|
30
|
+
{ $item-version }<if test="$show-date = 'true' "> - { substring( //time/*[@dce-object-name = $item-version ], 1,10)}</if>
|
|
29
31
|
</option>
|
|
30
32
|
</for-each>
|
|
31
33
|
<for-each select="//versions/*">
|
|
32
34
|
<if test="./@version = $current-version">
|
|
33
35
|
<option selected value="{./@version}">
|
|
34
36
|
<variable name="item-version">{./@version}</variable>
|
|
35
|
-
{ $item-version } - { substring( //time/*[@dce-object-name = $item-version ], 1,10)}
|
|
37
|
+
{ $item-version }<if test="$show-date = 'true' "> - { substring( //time/*[@dce-object-name = $item-version ], 1,10)}</if>
|
|
36
38
|
</option>
|
|
37
39
|
</if>
|
|
38
40
|
</for-each>
|
|
@@ -41,25 +43,52 @@
|
|
|
41
43
|
</template>
|
|
42
44
|
|
|
43
45
|
<template id="npm-version-to-url">
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
substring-after($url, $current-version) ) }</attribute>
|
|
53
|
-
<attribute name="method">location.href</attribute>
|
|
54
|
-
</if>
|
|
55
|
-
</location-element>
|
|
56
|
-
<http-request
|
|
57
|
-
url="https://registry.npmjs.org/@epa-wg/custom-element-dist"
|
|
58
|
-
method="GET"
|
|
59
|
-
header-accept="application/json"
|
|
60
|
-
slice="versions-ajax" ></http-request>
|
|
46
|
+
<attribute name="package-name"></attribute>
|
|
47
|
+
<attribute name="value" select="//selected-version"></attribute>
|
|
48
|
+
<variable name="url" select="//window-location/value/@href"></variable>
|
|
49
|
+
|
|
50
|
+
<variable name="url-version">0{
|
|
51
|
+
substring-before(substring-after(substring($url, string-length(substring-before($url, '/')) -
|
|
52
|
+
string-length(substring-before(substring-before($url, '/'), '@0')) + 2), '@0'), '/')
|
|
53
|
+
}</variable>
|
|
61
54
|
|
|
62
|
-
|
|
63
|
-
|
|
55
|
+
<location-element slice="window-location" live>
|
|
56
|
+
<if test="//selected-version">
|
|
57
|
+
<if test=" not(//url-version = //selected-version ) ">
|
|
58
|
+
<attribute name="src">{ concat( substring-before($url, $url-version),
|
|
59
|
+
//selected-version,
|
|
60
|
+
substring-after($url, $url-version) ) }
|
|
61
|
+
</attribute>
|
|
62
|
+
<attribute name="method">location.href</attribute>
|
|
63
|
+
</if>
|
|
64
|
+
</if>
|
|
65
|
+
</location-element>
|
|
66
|
+
|
|
67
|
+
<http-request
|
|
68
|
+
url="https://registry.npmjs.org/{$package-name}"
|
|
69
|
+
method="GET"
|
|
70
|
+
header-accept="application/json"
|
|
71
|
+
slice="versions-ajax"></http-request>
|
|
72
|
+
|
|
73
|
+
<label>
|
|
74
|
+
<slot name="label">{$package-name} version:</slot>
|
|
75
|
+
<xhtml:select slice="selected-version" autocomplete="off" name="version">
|
|
76
|
+
<for-each select="//versions/*">
|
|
77
|
+
<option value="{./@version}">
|
|
78
|
+
<variable name="item-version">{./@version}</variable>
|
|
79
|
+
{ $item-version } - { substring( //time/*[@dce-object-name = $item-version ], 1,10)}
|
|
80
|
+
</option>
|
|
81
|
+
</for-each>
|
|
82
|
+
<for-each select="//versions/*">
|
|
83
|
+
<if test="./@version = $url-version">
|
|
84
|
+
<option selected value="{./@version}">
|
|
85
|
+
<variable name="item-version">{./@version}</variable>
|
|
86
|
+
{ $item-version } - { substring( //time/*[@dce-object-name = $item-version ], 1,10)}
|
|
87
|
+
</option>
|
|
88
|
+
</if>
|
|
89
|
+
</for-each>
|
|
90
|
+
</xhtml:select>
|
|
91
|
+
</label>
|
|
92
|
+
</template>
|
|
64
93
|
</body>
|
|
65
94
|
</html>
|
package/demo/s.xml
CHANGED
|
@@ -1,28 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
<
|
|
3
|
-
|
|
4
|
-
<span xmlns="http://www.w3.org/1999/xhtml" slot=""></span>
|
|
5
|
-
<npm-version xmlns="http://www.w3.org/1999/xhtml" slice="selected-version" package-name="@epa-wg/custom-element"
|
|
6
|
-
slot=""></npm-version>
|
|
7
|
-
<span xmlns="http://www.w3.org/1999/xhtml" slot=""></span>
|
|
8
|
-
<p xmlns="http://www.w3.org/1999/xhtml" slot="">
|
|
9
|
-
<code>selected-version</code>
|
|
10
|
-
slice: {//selected-version}
|
|
11
|
-
</p>
|
|
12
|
-
<span xmlns="http://www.w3.org/1999/xhtml" slot=""></span>
|
|
13
|
-
</payload>
|
|
14
|
-
<attributes>
|
|
15
|
-
<tag>dce-bbc8e8b4-575f-40d3-9880-2f1d56d85d80</tag>
|
|
16
|
-
</attributes>
|
|
17
|
-
<dataset/>
|
|
18
|
-
<slice>
|
|
19
|
-
<selected-version xmlns="" slice="selected-version" package-name="@epa-wg/custom-element" data-dce-id="2"
|
|
20
|
-
current-version="" value="0.0.21">
|
|
21
|
-
<event isTrusted="false" sliceProcessed="1" type="change" eventPhase="2" bubbles="true" cancelable="false"
|
|
22
|
-
defaultPrevented="false" composed="false" timeStamp="2225577.4000000954" returnValue="true"
|
|
23
|
-
cancelBubble="false" NONE="0" CAPTURING_PHASE="1" AT_TARGET="2" BUBBLING_PHASE="3">
|
|
24
|
-
<detail package-name="@epa-wg/custom-element"/>
|
|
25
|
-
</event>
|
|
26
|
-
</selected-version>
|
|
27
|
-
</slice>
|
|
28
|
-
</datadom>
|
|
1
|
+
<body xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"><h4>embed-1.html</h4>
|
|
2
|
+
<custom-element><template>🖖</template></custom-element>
|
|
3
|
+
</body>
|
package/demo/s.xslt
CHANGED
|
@@ -1,97 +1,56 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
<xsl:
|
|
10
|
-
<xsl:value-of select="def"/>
|
|
11
|
-
</xsl:otherwise>
|
|
12
|
-
</xsl:choose>
|
|
13
|
-
<xsl:value-of select="."/>
|
|
14
|
-
</xsl:template>
|
|
15
|
-
<xsl:template mode="payload" match="attributes">
|
|
16
|
-
<dce-root xmlns="http://www.w3.org/1999/xhtml" xmlns:xhtml="http://www.w3.org/1999/xhtml" data-dce-id="1">
|
|
17
|
-
<xsl:variable xmlns:xsl="http://www.w3.org/1999/XSL/Transform" name="methods">
|
|
18
|
-
<a xmlns="" href="https://developer.mozilla.org/en-US/docs/Web/API/Location/href" data-dce-id="2">
|
|
19
|
-
location.href
|
|
20
|
-
</a>
|
|
21
|
-
<a xmlns="" href="https://developer.mozilla.org/en-US/docs/Web/API/Location/hash" data-dce-id="3">
|
|
22
|
-
location.hash
|
|
23
|
-
</a>
|
|
24
|
-
<a xmlns="" href="https://developer.mozilla.org/en-US/docs/Web/API/Location/assign" data-dce-id="4">
|
|
25
|
-
location.assign
|
|
26
|
-
</a>
|
|
27
|
-
</xsl:variable>
|
|
28
|
-
<fieldset xmlns="" data-dce-id="5">
|
|
29
|
-
<legend data-dce-id="6">
|
|
30
|
-
<b data-dce-id="7">set-by</b>
|
|
31
|
-
</legend>
|
|
32
|
-
<xsl:for-each xmlns:xsl="http://www.w3.org/1999/XSL/Transform" select="$methods">
|
|
33
|
-
<p data-dce-id="8">
|
|
34
|
-
<label data-dce-id="9">
|
|
35
|
-
<input type="radio" name="method" value="{.}" data-dce-id="10"/>
|
|
36
|
-
<dce-text data-dce-id="11">
|
|
37
|
-
<xsl:value-of select="."/>
|
|
38
|
-
</dce-text>
|
|
39
|
-
</label>
|
|
40
|
-
<a class="infolink" href="https://developer.mozilla.org/en-US/docs/Web/API/Location/assign"
|
|
41
|
-
data-dce-id="12">mdn
|
|
42
|
-
</a>
|
|
43
|
-
</p>
|
|
44
|
-
</xsl:for-each>
|
|
45
|
-
<label data-dce-id="13">
|
|
46
|
-
<input type="radio" name="method" value="location.href" data-dce-id="14"/>
|
|
47
|
-
<dce-text data-dce-id="15">location.href</dce-text>
|
|
48
|
-
</label>
|
|
49
|
-
<label data-dce-id="16">
|
|
50
|
-
<input type="radio" name="method" value="location" data-dce-id="17"/>
|
|
51
|
-
<dce-text data-dce-id="18">location</dce-text>
|
|
52
|
-
</label>
|
|
53
|
-
<label data-dce-id="19">
|
|
54
|
-
<input type="radio" name="method" value="location.replace" data-dce-id="20"/>
|
|
55
|
-
<dce-text data-dce-id="21">location.replace</dce-text>
|
|
56
|
-
</label>
|
|
57
|
-
<label data-dce-id="22">
|
|
58
|
-
<input type="radio" name="method" value="location.assign" data-dce-id="23"/>
|
|
59
|
-
<dce-text data-dce-id="24">location.assign</dce-text>
|
|
60
|
-
</label>
|
|
61
|
-
<label data-dce-id="25">
|
|
62
|
-
<input type="radio" name="method" value="location.hash" data-dce-id="26"/>
|
|
63
|
-
<dce-text data-dce-id="27">location.hash</dce-text>
|
|
64
|
-
</label>
|
|
65
|
-
<label data-dce-id="28">
|
|
66
|
-
<input type="radio" name="method" value="history.pushState" data-dce-id="29"/>
|
|
67
|
-
<dce-text data-dce-id="30">history.pushState</dce-text>
|
|
68
|
-
</label>
|
|
69
|
-
<label data-dce-id="31">
|
|
70
|
-
<input type="radio" name="method" value="history.replaceState" data-dce-id="32"/>
|
|
71
|
-
<dce-text data-dce-id="33">history.replaceState</dce-text>
|
|
72
|
-
</label>
|
|
73
|
-
</fieldset>
|
|
1
|
+
<?xml version='1.0' encoding='UTF-8'?>
|
|
2
|
+
<xsl:stylesheet version="1.0"
|
|
3
|
+
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
|
|
4
|
+
xmlns:xhtml="http://www.w3.org/1999/xhtml"
|
|
5
|
+
>
|
|
6
|
+
<xsl:output method="xml"/>
|
|
7
|
+
<xsl:template match="/">
|
|
8
|
+
<dce-root >
|
|
9
|
+
<xsl:apply-templates select="*"/>
|
|
74
10
|
</dce-root>
|
|
75
11
|
</xsl:template>
|
|
76
|
-
<xsl:template match="
|
|
77
|
-
<xsl:apply-templates mode="
|
|
12
|
+
<xsl:template match="*[name()='template']">
|
|
13
|
+
<xsl:apply-templates mode="sanitize" select="*|text()"/>
|
|
14
|
+
</xsl:template>
|
|
15
|
+
<xsl:template match="*">
|
|
16
|
+
<xsl:apply-templates mode="sanitize" select="*|text()"/>
|
|
17
|
+
</xsl:template>
|
|
18
|
+
<xsl:template match="*[name()='svg']|*[name()='math']">
|
|
19
|
+
<xsl:apply-templates mode="sanitize" select="."/>
|
|
20
|
+
</xsl:template>
|
|
21
|
+
<xsl:template mode="sanitize" match="*[count(text())=1 and count(*)=0]">
|
|
22
|
+
<xsl:copy>
|
|
23
|
+
<xsl:apply-templates mode="sanitize" select="@*"/>
|
|
24
|
+
<xsl:value-of select="text()"></xsl:value-of>
|
|
25
|
+
</xsl:copy>
|
|
26
|
+
</xsl:template>
|
|
27
|
+
<xsl:template mode="sanitize" match="xhtml:*[count(text())=1 and count(*)=0]">
|
|
28
|
+
<xsl:element name="{local-name()}">
|
|
29
|
+
<xsl:apply-templates mode="sanitize" select="@*"/>
|
|
30
|
+
<xsl:value-of select="text()"></xsl:value-of>
|
|
31
|
+
</xsl:element>
|
|
32
|
+
</xsl:template>
|
|
33
|
+
<xsl:template mode="sanitize" match="*|@*">
|
|
34
|
+
<xsl:copy>
|
|
35
|
+
<xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
|
|
36
|
+
</xsl:copy>
|
|
37
|
+
</xsl:template>
|
|
38
|
+
<xsl:template mode="sanitize" match="text()[normalize-space(.) = '']"/>
|
|
39
|
+
<xsl:template mode="sanitize" match="text()">
|
|
40
|
+
<dce-text>
|
|
41
|
+
<xsl:copy/>
|
|
42
|
+
</dce-text>
|
|
43
|
+
</xsl:template>
|
|
44
|
+
<xsl:template mode="sanitize" match="xsl:value-of|*[name()='slot']">
|
|
45
|
+
<dce-text>
|
|
46
|
+
<xsl:copy>
|
|
47
|
+
<xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
|
|
48
|
+
</xsl:copy>
|
|
49
|
+
</dce-text>
|
|
78
50
|
</xsl:template>
|
|
79
|
-
<xsl:template
|
|
80
|
-
<xsl:
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
<xsl:when test="//payload/*[@slot=$slotname]">
|
|
84
|
-
<xsl:copy-of select="//payload/*[@slot=$slotname]"/>
|
|
85
|
-
</xsl:when>
|
|
86
|
-
<xsl:otherwise>
|
|
87
|
-
<xsl:copy-of select="$defaultvalue"/>
|
|
88
|
-
</xsl:otherwise>
|
|
89
|
-
</xsl:choose>
|
|
51
|
+
<xsl:template mode="sanitize" match="xhtml:*">
|
|
52
|
+
<xsl:element name="{local-name()}">
|
|
53
|
+
<xsl:apply-templates mode="sanitize" select="*|@*|text()"/>
|
|
54
|
+
</xsl:element>
|
|
90
55
|
</xsl:template>
|
|
91
|
-
<xsl:variable name="js-injected-body">
|
|
92
|
-
<xsl:call-template name="slot">
|
|
93
|
-
<xsl:with-param name="slotname" select="''"/>
|
|
94
|
-
<xsl:with-param name="defaultvalue"/>
|
|
95
|
-
</xsl:call-template>
|
|
96
|
-
</xsl:variable>
|
|
97
56
|
</xsl:stylesheet>
|
package/demo/z.html
CHANGED
|
@@ -1,62 +1,33 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
<th data-dce-id="11">hostname</th>
|
|
28
|
-
<td data-dce-id="12">localhost</td>
|
|
29
|
-
</tr>
|
|
30
|
-
<tr data-dce-id="10-5">
|
|
31
|
-
<th data-dce-id="11">port</th>
|
|
32
|
-
<td data-dce-id="12">63342</td>
|
|
33
|
-
</tr>
|
|
34
|
-
<tr data-dce-id="10-6">
|
|
35
|
-
<th data-dce-id="11">pathname</th>
|
|
36
|
-
<td data-dce-id="12">/custom-element/demo/a.html</td>
|
|
37
|
-
</tr>
|
|
38
|
-
<tr data-dce-id="10-7">
|
|
39
|
-
<th data-dce-id="11">search</th>
|
|
40
|
-
<td data-dce-id="12">?_ijt=dmv0p4go000q47lg48i5im92f7&_ij_reload=RELOAD_ON_SAVE</td>
|
|
41
|
-
</tr>
|
|
42
|
-
<tr data-dce-id="10-8">
|
|
43
|
-
<th data-dce-id="11">hash</th>
|
|
44
|
-
<td data-dce-id="12"></td>
|
|
45
|
-
</tr>
|
|
46
|
-
</tbody>
|
|
47
|
-
</table>
|
|
48
|
-
<h3 data-dce-id="9"> URL parameters </h3>
|
|
49
|
-
<table xmlns="" data-dce-id="8">
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
|
3
|
+
<head>
|
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
5
|
+
<title>DOM merge - Declarative Custom Element implementation demo</title>
|
|
6
|
+
<link rel="icon" href="./wc-square.svg"/>
|
|
7
|
+
<script type="importmap">
|
|
8
|
+
{
|
|
9
|
+
"imports": {
|
|
10
|
+
"@epa-wg/custom-element/": "../",
|
|
11
|
+
"@epa-wg/custom-element-dist/": "../"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
</script>
|
|
15
|
+
<script type="module" src="../http-request.js"></script>
|
|
16
|
+
<script type="module" src="../location-element.js"></script>
|
|
17
|
+
<script type="module" src="../custom-element.js"></script>
|
|
18
|
+
<style>
|
|
19
|
+
@import "./demo.css";
|
|
20
|
+
dt{ font-weight: bold}
|
|
21
|
+
dd{ padding: 0;}
|
|
22
|
+
h1,h3{ margin: 0;}
|
|
23
|
+
nav{ gap:0; }
|
|
24
|
+
</style>
|
|
25
|
+
</head>
|
|
26
|
+
<body>
|
|
50
27
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
<th data-dce-id="11">_ij_reload</th>
|
|
58
|
-
<td data-dce-id="12">RELOAD_ON_SAVE</td>
|
|
59
|
-
</tr>
|
|
60
|
-
</tbody>
|
|
61
|
-
</table>
|
|
62
|
-
</dce-root>
|
|
28
|
+
<custom-element src="./html-template.html#dwc-logo">
|
|
29
|
+
<template><i>loading SVG from templates file ...</i></template>
|
|
30
|
+
</custom-element>
|
|
31
|
+
|
|
32
|
+
</body>
|
|
33
|
+
</html>
|
package/demo/z1.html
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xhtml="http://www.w3.org/1999/xhtml">
|
|
3
|
+
<head>
|
|
4
|
+
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
5
|
+
<title>DOM merge - Declarative Custom Element implementation demo</title>
|
|
6
|
+
<link rel="icon" href="./wc-square.svg"/>
|
|
7
|
+
<script type="importmap">
|
|
8
|
+
{
|
|
9
|
+
"imports": {
|
|
10
|
+
"@epa-wg/custom-element/": "../",
|
|
11
|
+
"@epa-wg/custom-element-dist/": "../"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
</script>
|
|
15
|
+
<script type="module" src="../http-request.js"></script>
|
|
16
|
+
<script type="module" src="../location-element.js"></script>
|
|
17
|
+
<script type="module" src="../custom-element.js"></script>
|
|
18
|
+
<style>
|
|
19
|
+
@import "./demo.css";
|
|
20
|
+
dt{ font-weight: bold}
|
|
21
|
+
dd{ padding: 0;}
|
|
22
|
+
h1,h3{ margin: 0;}
|
|
23
|
+
nav{ gap:0; }
|
|
24
|
+
</style>
|
|
25
|
+
</head>
|
|
26
|
+
<body>
|
|
27
|
+
<button onclick="window.location.hash = `#@epa-wg/custom-element-dist@0.0.27/storybook-static/index.html`">set in page URL</button>
|
|
28
|
+
|
|
29
|
+
<custom-element src="@epa-wg/custom-element-dist/demo/npm-versions.html#npm-version"
|
|
30
|
+
package-name="@epa-wg/custom-element-dist"
|
|
31
|
+
></custom-element>
|
|
32
|
+
|
|
33
|
+
</body>
|
|
34
|
+
</html>
|
package/ide/web-types-dce.json
CHANGED
package/ide/web-types-xsl.json
CHANGED
package/index.html
CHANGED
|
@@ -4,7 +4,17 @@
|
|
|
4
4
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
5
5
|
<title>custom-element Declarative Custom Element implementation demo</title>
|
|
6
6
|
<link rel="icon" href="demo/wc-square.svg" />
|
|
7
|
-
<script type="
|
|
7
|
+
<script type="importmap">
|
|
8
|
+
{
|
|
9
|
+
"imports": {
|
|
10
|
+
"@epa-wg/custom-element/": "./",
|
|
11
|
+
"@epa-wg/custom-element-dist/": "./"
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
</script>
|
|
15
|
+
<script type="module" src="./http-request.js"></script>
|
|
16
|
+
<script type="module" src="./location-element.js"></script>
|
|
17
|
+
<script type="module" src="./custom-element.js"></script>
|
|
8
18
|
<style>
|
|
9
19
|
@import "demo/demo.css";
|
|
10
20
|
</style>
|
|
@@ -18,6 +28,12 @@
|
|
|
18
28
|
| <a href="https://stackblitz.com/github/EPA-WG/custom-element?file=index.html">Sandbox</a>
|
|
19
29
|
| <a href="https://chrome.google.com/webstore/detail/epa-wgcustom-element/hiofgpmmkdembdogjpagmbbbmefefhbl"
|
|
20
30
|
>Chrome devtools plugin</a>
|
|
31
|
+
| <custom-element src="@epa-wg/custom-element/demo/npm-versions.html#npm-version-to-url"
|
|
32
|
+
slice="selected" package-name="@epa-wg/custom-element">
|
|
33
|
+
<i slot="label">version:</i>
|
|
34
|
+
</custom-element>
|
|
35
|
+
|
|
36
|
+
|
|
21
37
|
</div>
|
|
22
38
|
<p>
|
|
23
39
|
This <em>Declarative Custom Element</em> allows to define<br/>
|
|
@@ -38,7 +54,8 @@
|
|
|
38
54
|
<a href="./demo/parameters.html" >attributes </a> |
|
|
39
55
|
<a href="./demo/data-slices.html" >data slices/events </a> |
|
|
40
56
|
<a href="./demo/form.html" >Form validation </a> |
|
|
41
|
-
<a href="./demo/dom-merge.html" >DOM merge on dynamic update </a
|
|
57
|
+
<a href="./demo/dom-merge.html" >DOM merge on dynamic update </a><br/>
|
|
58
|
+
<a href="./demo/npm-versions-demo.html">npm version </a>
|
|
42
59
|
</section>
|
|
43
60
|
</nav>
|
|
44
61
|
<html-demo-element legend="1. simple payload"
|
package/local-storage.js
CHANGED
|
@@ -21,29 +21,34 @@ const string2value = (type, v) =>
|
|
|
21
21
|
|
|
22
22
|
let originalSetItem,originalRemoveItem,originalClear;
|
|
23
23
|
|
|
24
|
+
export function localStorage_setItem( key, value )
|
|
25
|
+
{ originalSetItem.call(localStorage, key, value);
|
|
26
|
+
window.dispatchEvent( new CustomEvent('local-storage',{detail:{key,value}}) );
|
|
27
|
+
}
|
|
28
|
+
export function localStorage_removeItem( key )
|
|
29
|
+
{ originalRemoveItem.call(localStorage, key);
|
|
30
|
+
window.dispatchEvent( new CustomEvent('local-storage',{detail:{key}}) );
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export function localStorage_clear()
|
|
34
|
+
{ originalClear.call(localStorage);
|
|
35
|
+
window.dispatchEvent( new CustomEvent('local-storage',{detail:{}}) );
|
|
36
|
+
}
|
|
37
|
+
|
|
24
38
|
function ensureTrackLocalStorage()
|
|
25
39
|
{ if( originalSetItem )
|
|
26
40
|
return;
|
|
27
41
|
originalSetItem = localStorage.setItem;
|
|
28
|
-
localStorage.setItem =
|
|
29
|
-
{ originalSetItem.apply(this, [ key, value, ...rest ]);
|
|
30
|
-
window.dispatchEvent( new CustomEvent('local-storage',{detail:{key,value}}) );
|
|
31
|
-
};
|
|
42
|
+
localStorage.setItem = localStorage_setItem;
|
|
32
43
|
originalRemoveItem = localStorage.removeItem;
|
|
33
|
-
localStorage.removeItem =
|
|
34
|
-
{ originalRemoveItem.apply(this, [ key, ...rest ]);
|
|
35
|
-
window.dispatchEvent( new CustomEvent('local-storage',{detail:{key}}) );
|
|
36
|
-
};
|
|
44
|
+
localStorage.removeItem = localStorage_removeItem;
|
|
37
45
|
originalClear = localStorage.clear;
|
|
38
|
-
localStorage.clear =
|
|
39
|
-
{ originalClear.apply(this, [ ...rest ]);
|
|
40
|
-
window.dispatchEvent( new CustomEvent('local-storage',{detail:{}}) );
|
|
41
|
-
};
|
|
46
|
+
localStorage.clear = localStorage_clear;
|
|
42
47
|
}
|
|
48
|
+
ensureTrackLocalStorage();
|
|
43
49
|
|
|
44
50
|
export function localStorageSetItem(key, value)
|
|
45
|
-
{
|
|
46
|
-
window.dispatchEvent( new CustomEvent('local-storage',{detail:{key,value}}) );
|
|
51
|
+
{ localStorage_setItem(key, value);
|
|
47
52
|
}
|
|
48
53
|
export class LocalStorageElement extends HTMLElement
|
|
49
54
|
{
|
package/module-url.js
CHANGED
|
@@ -10,9 +10,10 @@ export class ModuleUrl extends HTMLElement
|
|
|
10
10
|
|
|
11
11
|
sliceInit()
|
|
12
12
|
{ let path = attr(this,'src');
|
|
13
|
+
|
|
13
14
|
try
|
|
14
15
|
{ const url = '.' === path.charAt(0)
|
|
15
|
-
? new URL(path, this.closest('[base]')?.getAttribute('base') ).href
|
|
16
|
+
? new URL(path, this.closest('[base]')?.getAttribute('base') || location.href).href
|
|
16
17
|
: import.meta.resolve(path);
|
|
17
18
|
this.setAttribute('value',this.value = url );
|
|
18
19
|
}catch( er )
|
|
@@ -30,4 +31,4 @@ export class ModuleUrl extends HTMLElement
|
|
|
30
31
|
}
|
|
31
32
|
|
|
32
33
|
window.customElements.define( 'module-url', ModuleUrl );
|
|
33
|
-
export default ModuleUrl;
|
|
34
|
+
export default ModuleUrl;
|
package/package.json
CHANGED
package/request.html
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
|
|
3
|
-
<head>
|
|
4
|
-
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
|
|
5
|
-
<title>custom-element Declarative Custom Element implementation demo</title>
|
|
6
|
-
<script type="module" src="custom-element.js"></script>
|
|
7
|
-
<style>
|
|
8
|
-
body,nav{ display: flex; flex-wrap: wrap; align-content: stretch; gap: 1rem; }
|
|
9
|
-
nav{ flex-direction: column;}
|
|
10
|
-
dce-link,dce-1-slot,dce-2-slot,dce-3-slot,dce-4-slot,dce-2-slots,greet-element,pokemon-tile
|
|
11
|
-
{ box-shadow: 0 0 0.5rem lime; padding: 1rem; display: inline-block;}
|
|
12
|
-
dd{ padding: 1rem;}
|
|
13
|
-
p{ margin: 0;}
|
|
14
|
-
</style>
|
|
15
|
-
</head>
|
|
16
|
-
<body>
|
|
17
|
-
|
|
18
|
-
<html-demo-element legend="1. simple payload"
|
|
19
|
-
description="payload is ignored as in DCE definition there is no default slot">
|
|
20
|
-
<template>
|
|
21
|
-
<custom-element tag="poke-image-request" hidden>
|
|
22
|
-
<img src="https://unpkg.com/pokeapi-sprites@2.0.2/sprites/pokemon/other/dream-world/{//poke-id}.svg"/>
|
|
23
|
-
</custom-element>
|
|
24
|
-
<poke-image-request poke-id="1"></poke-image-request>
|
|
25
|
-
|
|
26
|
-
<custom-element tag="poke-list-request" hidden>
|
|
27
|
-
<a href="https://pokeapi.co/api/v2/pokemon?offset={//offset}&limit=10">list json</a>
|
|
28
|
-
</custom-element>
|
|
29
|
-
|
|
30
|
-
<custom-element tag="poke-list-page" hidden>
|
|
31
|
-
<a href="https://pokeapi.co/api/v2/pokemon?offset={//offset}&limit=10">list json</a>
|
|
32
|
-
<http-request-json
|
|
33
|
-
target="poke-list"
|
|
34
|
-
src="https://pokeapi.co/api/v2/pokemon?offset={//offset}&limit=10"
|
|
35
|
-
></http-request-json>
|
|
36
|
-
<ol>
|
|
37
|
-
<for-each select="">
|
|
38
|
-
|
|
39
|
-
</for-each>
|
|
40
|
-
</ol>
|
|
41
|
-
</custom-element>
|
|
42
|
-
<poke-list-page>
|
|
43
|
-
<poke-list-request offset="0"></poke-list-request>
|
|
44
|
-
</poke-list-page>
|
|
45
|
-
|
|
46
|
-
</template>
|
|
47
|
-
</html-demo-element>
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
<script type="module" src="https://unpkg.com/html-demo-element@1.0/html-demo-element.js"></script>
|
|
51
|
-
|
|
52
|
-
</body>
|
|
53
|
-
</html>
|