@epa-wg/custom-element 0.0.11 → 0.0.12

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/demo/template.xsl CHANGED
@@ -1,46 +1,46 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3
- <xsl:output method="html"/>
4
-
5
- <xsl:template match="/">
6
- <xsl:apply-templates select="//attributes"/>
7
- </xsl:template>
8
- <xsl:template match="attributes">
9
- <h3 xmlns="http://www.w3.org/1999/xhtml">
10
- <xsl:value-of select="title"></xsl:value-of>
11
- </h3> <!-- title is an attribute in instance
12
- mapped into /*/attributes/title -->
13
- <xsl:if xmlns="http://www.w3.org/1999/xhtml" test="//smile"> <!-- data-smile DCE instance attribute,
14
- mapped into /*/dataset/smile
15
- used in condition -->
16
- <!-- data-smile DCE instance attribute, used as HTML -->
17
- <div>Smile as:
18
- <xsl:value-of select="//smile"></xsl:value-of>
19
- </div>
20
- </xsl:if>
21
- <!-- image would not be visible in sandbox, see live demo -->
22
- <img xmlns="http://www.w3.org/1999/xhtml"
23
- src="https://unpkg.com/pokeapi-sprites@2.0.2/sprites/pokemon/other/dream-world/{pokemon-id}.svg"
24
- alt="{title} image"/>
25
- <!-- image-src and title are DCE instance attributes,
26
- mapped into /*/attributes/
27
- used within output attribute via curly brackets -->
28
-
29
- <!-- `slot name=xxx` replaced with elements with `slot=xxx` attribute -->
30
- <p xmlns="http://www.w3.org/1999/xhtml">
31
- <xsl:value-of select="//*[@slot=&quot;description&quot;]"/>
32
- </p>
33
- <xsl:for-each xmlns="http://www.w3.org/1999/xhtml" select="//*[@pokemon-id]">
34
- <!-- loop over payload elements with `pokemon-id` attribute -->
35
- <button>
36
- <img height="32"
37
- src="https://unpkg.com/pokeapi-sprites@2.0.2/sprites/pokemon/other/dream-world/{@pokemon-id}.svg"
38
- alt="{text()}"/>
39
- <br/>
40
- <xsl:value-of select="text()">
41
- </xsl:value-of>
42
- </button>
43
-
44
- </xsl:for-each>
45
- </xsl:template>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
3
+ <xsl:output method="html"/>
4
+
5
+ <xsl:template match="/">
6
+ <xsl:apply-templates select="//attributes"/>
7
+ </xsl:template>
8
+ <xsl:template match="attributes">
9
+ <h3 xmlns="http://www.w3.org/1999/xhtml">
10
+ <xsl:value-of select="title"></xsl:value-of>
11
+ </h3> <!-- title is an attribute in instance
12
+ mapped into /*/attributes/title -->
13
+ <xsl:if xmlns="http://www.w3.org/1999/xhtml" test="//smile"> <!-- data-smile DCE instance attribute,
14
+ mapped into /*/dataset/smile
15
+ used in condition -->
16
+ <!-- data-smile DCE instance attribute, used as HTML -->
17
+ <div>Smile as:
18
+ <xsl:value-of select="//smile"></xsl:value-of>
19
+ </div>
20
+ </xsl:if>
21
+ <!-- image would not be visible in sandbox, see live demo -->
22
+ <img xmlns="http://www.w3.org/1999/xhtml"
23
+ src="https://unpkg.com/pokeapi-sprites@2.0.2/sprites/pokemon/other/dream-world/{pokemon-id}.svg"
24
+ alt="{title} image"/>
25
+ <!-- image-src and title are DCE instance attributes,
26
+ mapped into /*/attributes/
27
+ used within output attribute via curly brackets -->
28
+
29
+ <!-- `slot name=xxx` replaced with elements with `slot=xxx` attribute -->
30
+ <p xmlns="http://www.w3.org/1999/xhtml">
31
+ <xsl:value-of select="//*[@slot=&quot;description&quot;]"/>
32
+ </p>
33
+ <xsl:for-each xmlns="http://www.w3.org/1999/xhtml" select="//*[@pokemon-id]">
34
+ <!-- loop over payload elements with `pokemon-id` attribute -->
35
+ <button>
36
+ <img height="32"
37
+ src="https://unpkg.com/pokeapi-sprites@2.0.2/sprites/pokemon/other/dream-world/{@pokemon-id}.svg"
38
+ alt="{text()}"/>
39
+ <br/>
40
+ <xsl:value-of select="text()">
41
+ </xsl:value-of>
42
+ </button>
43
+
44
+ </xsl:for-each>
45
+ </xsl:template>
46
46
  </xsl:stylesheet>
package/demo/tree.xml CHANGED
@@ -1,25 +1,25 @@
1
- <?xml version="1.0" encoding="UTF-8"?>
2
- <?xml-stylesheet type="text/xsl" href="tree.xsl"?>
3
- <div xmlns="http://www.w3.org/1999/xhtml">
4
- <payload>
5
- <span slot=""></span>
6
- <p slot="description">Bulbasaur is a cute Pokémon born with a large seed firmly affixed to its back;
7
- the seed grows in size as the Pokémon does.
8
- </p>
9
- <span slot=""></span>
10
- <ul slot="">
11
- <li pokemon-id="2">ivysaur</li>
12
- <li pokemon-id="3">venusaur</li>
13
- </ul>
14
- <span slot=""></span>
15
- </payload>
16
- <attributes>
17
- <title>bulbasaur</title>
18
- <data-smile>👼</data-smile>
19
- <pokemon-id>1</pokemon-id>
20
- </attributes>
21
- <dataset>
22
- <smile>👼</smile>
23
- </dataset>
24
- <slice></slice>
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <?xml-stylesheet type="text/xsl" href="tree.xsl"?>
3
+ <div xmlns="http://www.w3.org/1999/xhtml">
4
+ <payload>
5
+ <span slot=""></span>
6
+ <p slot="description">Bulbasaur is a cute Pokémon born with a large seed firmly affixed to its back;
7
+ the seed grows in size as the Pokémon does.
8
+ </p>
9
+ <span slot=""></span>
10
+ <ul slot="">
11
+ <li pokemon-id="2">ivysaur</li>
12
+ <li pokemon-id="3">venusaur</li>
13
+ </ul>
14
+ <span slot=""></span>
15
+ </payload>
16
+ <attributes>
17
+ <title>bulbasaur</title>
18
+ <data-smile>👼</data-smile>
19
+ <pokemon-id>1</pokemon-id>
20
+ </attributes>
21
+ <dataset>
22
+ <smile>👼</smile>
23
+ </dataset>
24
+ <slice></slice>
25
25
  </div>
package/demo/tree.xsl CHANGED
@@ -1,33 +1,33 @@
1
- <xsl:stylesheet version="1.0"
2
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3
- <xsl:output
4
- method="html"
5
- omit-xml-declaration="yes"
6
- standalone="yes"
7
- indent="yes"
8
- />
9
-
10
- <xsl:template match="/">
11
- <xsl:apply-templates select="*"/>
12
- </xsl:template>
13
- <xsl:template match="*">
14
- <details style="padding:0 1rem" open="open">
15
- <summary>
16
- <b style="color:green"><xsl:value-of select="name()"/></b>
17
- <xsl:apply-templates select="@*"/>
18
- </summary>
19
- <xsl:value-of select="./text()"/>
20
- <xsl:apply-templates select="*"/>
21
- </details>
22
- </xsl:template>
23
- <xsl:template match="@*">
24
- <code style="margin-left:1rem;color:brown"><xsl:value-of select="name()"/>="<xsl:value-of select="."/>"</code>
25
- </xsl:template>
26
- <xsl:template match="text()">
27
- <p>
28
- <xsl:value-of select="."/>
29
- </p>
30
- </xsl:template>
31
-
32
-
1
+ <xsl:stylesheet version="1.0"
2
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3
+ <xsl:output
4
+ method="html"
5
+ omit-xml-declaration="yes"
6
+ standalone="yes"
7
+ indent="yes"
8
+ />
9
+
10
+ <xsl:template match="/">
11
+ <xsl:apply-templates select="*"/>
12
+ </xsl:template>
13
+ <xsl:template match="*">
14
+ <details style="padding:0 1rem" open="open">
15
+ <summary>
16
+ <b style="color:green"><xsl:value-of select="name()"/></b>
17
+ <xsl:apply-templates select="@*"/>
18
+ </summary>
19
+ <xsl:value-of select="./text()"/>
20
+ <xsl:apply-templates select="*"/>
21
+ </details>
22
+ </xsl:template>
23
+ <xsl:template match="@*">
24
+ <code style="margin-left:1rem;color:brown"><xsl:value-of select="name()"/>="<xsl:value-of select="."/>"</code>
25
+ </xsl:template>
26
+ <xsl:template match="text()">
27
+ <p>
28
+ <xsl:value-of select="."/>
29
+ </p>
30
+ </xsl:template>
31
+
32
+
33
33
  </xsl:stylesheet>
@@ -1,45 +1,45 @@
1
- <!DOCTYPE html>
2
- <html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3
- <head>
4
- <meta charset="UTF-8">
5
- <title>template based on HTML file</title>
6
- </head>
7
- <body>
8
- <b id="wave">👋</b>
9
- <b id="ok">👌</b>
10
- <svg id="dwc-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 216 209.18"><defs><style>.cls-1{fill:#c2e6f1;}.cls-2{fill:#dcf1f7;}.cls-3{fill:#2d4554;}.cls-4{fill:#60cae5;}</style></defs><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/></svg>
11
- <xsl:stylesheet
12
- id="embedded-xsl"
13
- version="1.0"
14
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
15
- <xsl:output
16
- method="html"
17
- omit-xml-declaration="yes"
18
- standalone="yes"
19
- indent="yes"
20
- />
21
-
22
- <xsl:template match="/">
23
- <xsl:apply-templates select="*"/>
24
- </xsl:template>
25
- <xsl:template match="*">
26
- <details style="padding:0 1rem" open="open">
27
- <summary>
28
- <b style="color:green"><xsl:value-of select="name()"/></b>
29
- <xsl:apply-templates select="@*"/>
30
- </summary>
31
- <xsl:value-of select="./text()"/>
32
- <xsl:apply-templates select="*"/>
33
- </details>
34
- </xsl:template>
35
- <xsl:template match="@*">
36
- <code style="margin-left:1rem;color:brown"><xsl:value-of select="name()"/>="<xsl:value-of select="."/>"</code>
37
- </xsl:template>
38
- <xsl:template match="text()">
39
- <p>
40
- <xsl:value-of select="."/>
41
- </p>
42
- </xsl:template>
43
- </xsl:stylesheet>
44
- </body>
1
+ <!DOCTYPE html>
2
+ <html lang="en" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <title>template based on HTML file</title>
6
+ </head>
7
+ <body>
8
+ <b id="wave">👋</b>
9
+ <b id="ok">👌</b>
10
+ <svg id="dwc-logo" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 216 209.18"><defs><style>.cls-1{fill:#c2e6f1;}.cls-2{fill:#dcf1f7;}.cls-3{fill:#2d4554;}.cls-4{fill:#60cae5;}</style></defs><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/><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"/></svg>
11
+ <xsl:stylesheet
12
+ id="embedded-xsl"
13
+ version="1.0"
14
+ xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
15
+ <xsl:output
16
+ method="html"
17
+ omit-xml-declaration="yes"
18
+ standalone="yes"
19
+ indent="yes"
20
+ />
21
+
22
+ <xsl:template match="/">
23
+ <xsl:apply-templates select="*"/>
24
+ </xsl:template>
25
+ <xsl:template match="*">
26
+ <details style="padding:0 1rem" open="open">
27
+ <summary>
28
+ <b style="color:green"><xsl:value-of select="name()"/></b>
29
+ <xsl:apply-templates select="@*"/>
30
+ </summary>
31
+ <xsl:value-of select="./text()"/>
32
+ <xsl:apply-templates select="*"/>
33
+ </details>
34
+ </xsl:template>
35
+ <xsl:template match="@*">
36
+ <code style="margin-left:1rem;color:brown"><xsl:value-of select="name()"/>="<xsl:value-of select="."/>"</code>
37
+ </xsl:template>
38
+ <xsl:template match="text()">
39
+ <p>
40
+ <xsl:value-of select="."/>
41
+ </p>
42
+ </xsl:template>
43
+ </xsl:stylesheet>
44
+ </body>
45
45
  </html>
package/demo/z.html ADDED
@@ -0,0 +1,42 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <dce-root data-dce-id="1" xmlns:dce="urn:schemas-epa-wg:dce" xmlns:xhtml="http://www.w3.org/1999/xhtml">
3
+ <table data-dce-id="2">
4
+ <tr data-dce-id="3">
5
+ <xhtml:th data-dce-id="4">href</xhtml:th>
6
+ <xhtml:td data-dce-id="5">http://localhost:63342/custom-element/demo/a.html?_ijt=qca6trk5kne6eo4s4tomq4egmm&amp;_ij_reload=RELOAD_ON_SAVE</xhtml:td>
7
+ </tr>
8
+ <tr data-dce-id="3">
9
+ <xhtml:th data-dce-id="4">origin</xhtml:th>
10
+ <xhtml:td data-dce-id="5">http://localhost:63342</xhtml:td>
11
+ </tr>
12
+ <tr data-dce-id="3">
13
+ <xhtml:th data-dce-id="4">protocol</xhtml:th>
14
+ <xhtml:td data-dce-id="5">http:</xhtml:td>
15
+ </tr>
16
+ <tr data-dce-id="3">
17
+ <xhtml:th data-dce-id="4">host</xhtml:th>
18
+ <xhtml:td data-dce-id="5">localhost:63342</xhtml:td>
19
+ </tr>
20
+ <tr data-dce-id="3">
21
+ <xhtml:th data-dce-id="4">hostname</xhtml:th>
22
+ <xhtml:td data-dce-id="5">localhost</xhtml:td>
23
+ </tr>
24
+ <tr data-dce-id="3">
25
+ <xhtml:th data-dce-id="4">port</xhtml:th>
26
+ <xhtml:td data-dce-id="5">63342</xhtml:td>
27
+ </tr>
28
+ <tr data-dce-id="3">
29
+ <xhtml:th data-dce-id="4">pathname</xhtml:th>
30
+ <xhtml:td data-dce-id="5">/custom-element/demo/a.html</xhtml:td>
31
+ </tr>
32
+ <tr data-dce-id="3">
33
+ <xhtml:th data-dce-id="4">search</xhtml:th>
34
+ <xhtml:td data-dce-id="5">?_ijt=qca6trk5kne6eo4s4tomq4egmm&amp;_ij_reload=RELOAD_ON_SAVE</xhtml:td>
35
+ </tr>
36
+ <tr data-dce-id="3">
37
+ <xhtml:th data-dce-id="4">hash</xhtml:th>
38
+ <xhtml:td data-dce-id="5"/>
39
+ </tr>
40
+ </table>
41
+ <location-element slice="window-url" data-dce-id="6"/>
42
+ </dce-root>
package/demo/z.xml ADDED
@@ -0,0 +1,60 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <dce-root data-dce-id="1" xmlns:dce="urn:schemas-epa-wg:dce" xmlns:xhtml="http://www.w3.org/1999/xhtml">
3
+ <location-element slice="window-url" data-dce-id="2"/>
4
+ <table data-dce-id="3">
5
+ <tr data-dce-id="4">
6
+ <th data-dce-id="5">
7
+ <u data-dce-id="6">URL properties</u>
8
+ </th>
9
+ </tr>
10
+ <tr data-dce-id="7">
11
+ <th data-dce-id="8">href</th>
12
+ <td data-dce-id="9">http://localhost:63342/custom-element/demo/a.html?_ijt=qca6trk5kne6eo4s4tomq4egmm&amp;_ij_reload=RELOAD_ON_SAVE</td>
13
+ </tr>
14
+ <tr data-dce-id="7">
15
+ <th data-dce-id="8">origin</th>
16
+ <td data-dce-id="9">http://localhost:63342</td>
17
+ </tr>
18
+ <tr data-dce-id="7">
19
+ <th data-dce-id="8">protocol</th>
20
+ <td data-dce-id="9">http:</td>
21
+ </tr>
22
+ <tr data-dce-id="7">
23
+ <th data-dce-id="8">host</th>
24
+ <td data-dce-id="9">localhost:63342</td>
25
+ </tr>
26
+ <tr data-dce-id="7">
27
+ <th data-dce-id="8">hostname</th>
28
+ <td data-dce-id="9">localhost</td>
29
+ </tr>
30
+ <tr data-dce-id="7">
31
+ <th data-dce-id="8">port</th>
32
+ <td data-dce-id="9">63342</td>
33
+ </tr>
34
+ <tr data-dce-id="7">
35
+ <th data-dce-id="8">pathname</th>
36
+ <td data-dce-id="9">/custom-element/demo/a.html</td>
37
+ </tr>
38
+ <tr data-dce-id="7">
39
+ <th data-dce-id="8">search</th>
40
+ <td data-dce-id="9">?_ijt=qca6trk5kne6eo4s4tomq4egmm&amp;_ij_reload=RELOAD_ON_SAVE</td>
41
+ </tr>
42
+ <tr data-dce-id="7">
43
+ <th data-dce-id="8">hash</th>
44
+ <td data-dce-id="9"/>
45
+ </tr>
46
+ <tr data-dce-id="10">
47
+ <th data-dce-id="11">
48
+ <u data-dce-id="12">URL parameters</u>
49
+ </th>
50
+ </tr>
51
+ <tr data-dce-id="13">
52
+ <th data-dce-id="14">_ijt</th>
53
+ <td data-dce-id="15">qca6trk5kne6eo4s4tomq4egmm</td>
54
+ </tr>
55
+ <tr data-dce-id="13">
56
+ <th data-dce-id="14">_ij_reload</th>
57
+ <td data-dce-id="15">RELOAD_ON_SAVE</td>
58
+ </tr>
59
+ </table>
60
+ </dce-root>
package/http-request.js CHANGED
@@ -2,58 +2,49 @@ const attr = (el, attr)=> el.getAttribute(attr);
2
2
 
3
3
  export class HttpRequestElement extends HTMLElement
4
4
  {
5
- // @attribute url
6
- constructor() {
7
- super();
5
+ static get observedAttributes() {
6
+ return [ 'value' // populated from localStorage, if defined initially, sets the value in storage
7
+ , 'slice'
8
+ , 'url'
9
+ , 'method'
10
+ , 'header-accept'
11
+ ]
8
12
  }
13
+
9
14
  get requestHeaders()
10
15
  { const ret = {};
11
16
  [...this.attributes].filter(a=>a.name.startsWith('header-')).map( a => ret[a.name.substring(7)] = a.value );
12
- return ret;
17
+ return ret
13
18
  }
14
19
  get requestProps()
15
20
  { const ret = {};
16
21
  [...this.attributes].filter(a=>!a.name.startsWith('header-')).map( a => ret[a.name] = a.value );
17
- return ret;
22
+ return ret
18
23
  }
19
- sliceInit( s )
20
- { if( !s )
21
- s = {};
22
- s.element = this;
23
- if( s.destroy )
24
- return s;
25
- const controller = new AbortController();
26
- s.destroy = ()=>
27
- { // todo destroy slices in custom-element
28
- controller.abort();
29
- };
24
+
25
+ disconnectedCallback(){ this._destroy?.(); }
26
+
27
+ connectedCallback()
28
+ { const controller = new AbortController();
29
+ this._destroy = ()=> controller.abort(this.localName+' disconnected');
30
+
30
31
  const url = attr(this, 'url') || ''
31
32
  , request = { ...this.requestProps, headers: this.requestHeaders }
32
- , slice = { detail: { request }, target: this }
33
- , updateSlice = slice =>
34
- { for( let parent = s.element.parentElement; parent; parent = parent.parentElement )
35
- if ( parent.onSlice )
36
- return parent.onSlice(slice);
37
- console.error(`${this.localName} used outside of custom-element`)
38
- debugger;
39
- };
40
-
33
+ , slice = { request }
34
+ , update = () => this.dispatchEvent( new Event('change') );
35
+ this.value = slice;
41
36
  setTimeout( async ()=>
42
- { updateSlice( slice );
37
+ { update();
43
38
  const response = await fetch(url,{ ...this.requestProps, signal: controller.signal, headers: this.requestHeaders })
44
- , r= {headers: {}};
45
- [...response.headers].map( ([k,v]) => r.headers[k]=v );
46
- 'ok,status,statusText,type,url,redirected'.split(',').map(k=>r[k]=response[k])
39
+ , r = {headers: {}};
40
+ [...response.headers].map( ([k,v]) => r.headers[k] = v );
41
+ 'ok,status,statusText,type,url,redirected'.split(',').map( k=> r[k] = response[k] )
47
42
 
48
- slice.detail.response = r;
49
- updateSlice( slice );
50
- const detail = {...slice.detail}
51
- detail.data = await response.json();
52
- const s = {...slice, detail}
53
- updateSlice( s );
43
+ slice.response = r;
44
+ update();
45
+ slice.data = await response.json();
46
+ update();
54
47
  },0 );
55
-
56
- return s;
57
48
  }
58
49
  }
59
50
 
package/index.html CHANGED
@@ -25,11 +25,12 @@
25
25
  The data query is powered by XPath. </p>
26
26
  <p>Try in <a href="https://stackblitz.com/github/EPA-WG/custom-element?file=index.html" >Sandbox</a> </p>
27
27
  <section>
28
- <b>Data layer demo</b>
28
+ <h4>Data layer demo</h4>
29
29
  <a href="./demo/local-storage.html" >local-storage </a> |
30
30
  <a href="./demo/http-request.html" >http-request </a> |
31
31
  <a href="./demo/location-element.html" >location-element </a> |
32
- <a href="./demo/external-template.html" >external template </a>
32
+ <a href="./demo/external-template.html" >external template </a> |
33
+ <a href="./demo/dom-merge.html" >DOM merge on dynamic update </a>
33
34
  </section>
34
35
  </nav>
35
36
  <html-demo-element legend="1. simple payload"
@@ -58,7 +59,7 @@
58
59
  <custom-element tag="dce-2-slots" hidden>
59
60
  <slot name="slot2"> 😃</slot> and again:
60
61
  <slot name="slot2"> 😃</slot>
61
- <input placeholder="🐇❤️{//*[@slot='slot2']}"/>
62
+ <xhtml:input placeholder="🐇❤️{//*[@slot='slot2']}"/>
62
63
  </custom-element>
63
64
  <dce-2-slots><i slot="slot2">🥕</i></dce-2-slots>
64
65
  <dce-2-slots></dce-2-slots>
@@ -108,13 +109,13 @@
108
109
 
109
110
  <custom-element tag="pokemon-tile" hidden id="shared-template">
110
111
  <template>
111
- <h3><xsl:value-of select="title"/></h3> <!-- title is an attribute in instance
112
- mapped into /*/attributes/title -->
113
- <xsl:if test="//smile"> <!-- data-smile DCE instance attribute,
114
- mapped into /*/dataset/smile
115
- used in condition -->
116
- <!-- data-smile DCE instance attribute, used as HTML -->
117
- <div>Smile as: <xsl:value-of select='//smile'/></div>
112
+ <h3> {title} </h3> <!-- title is an attribute in instance
113
+ mapped into /*/attributes/title -->
114
+ <xsl:if test="//smile"> <!-- data-smile DCE instance attribute,
115
+ mapped into /*/dataset/smile
116
+ used in condition -->
117
+ <!-- data-smile DCE instance attribute, used as HTML -->
118
+ <div>Smile as: {//smile}</div> <!-- /datadom/dataset/smile -->
118
119
  </xsl:if>
119
120
  <!-- image would not be visible in sandbox, see live demo -->
120
121
  <img src="https://unpkg.com/pokeapi-sprites@2.0.2/sprites/pokemon/other/dream-world/{pokemon-id}.svg"
@@ -126,16 +127,17 @@
126
127
  <!-- `slot name=xxx` replaced with elements with `slot=xxx` attribute -->
127
128
  <p><slot name="description"><i>description is not available</i></slot></p>
128
129
  <xsl:for-each select="//*[@pokemon-id]">
129
- <!-- loop over payload elements with `pokemon-id` attribute -->
130
- <button>
131
- <img height="32"
132
- src="https://unpkg.com/pokeapi-sprites@2.0.2/sprites/pokemon/other/dream-world/{@pokemon-id}.svg"
133
- alt="{text()}"/>
134
- <br/>
135
- <xsl:value-of select='text()'/>
136
- </button>
130
+ <!-- loop over payload elements with `pokemon-id` attribute,
131
+ i.e LI elements -->
132
+ <button>
133
+ <img height="32"
134
+ src="https://unpkg.com/pokeapi-sprites@2.0.2/sprites/pokemon/other/dream-world/{@pokemon-id}.svg"
135
+ alt="{text()}"/>
136
+ <br/>
137
+ {text()} <!-- text from LI element in loop -->
138
+ </button>
137
139
 
138
- </xsl:for-each>
140
+ </xsl:for-each>
139
141
  </template>
140
142
  </custom-element>
141
143
 
package/input-text.js ADDED
@@ -0,0 +1,17 @@
1
+ export class InputTextElement extends HTMLElement
2
+ {
3
+ constructor()
4
+ {
5
+ super();
6
+ const i = this.ownerDocument.createElement('input');
7
+ for(let a of this.attributes)
8
+ a.namespaceURI ? i.setAttributeNS(a.namespaceURI,a.name,a.value) : i.setAttribute(a.name,a.value)
9
+ this.append(i)
10
+ }
11
+ get value(){ return this.firstChild.value }
12
+ set value(v){ return this.firstChild.value = v }
13
+ disconnectedCallback(){ }
14
+ }
15
+
16
+ window.customElements.define( 'input-text', InputTextElement );
17
+ export default InputTextElement;