@epa-wg/custom-element-dist 0.0.35 → 0.0.37

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.
Files changed (123) hide show
  1. package/.ai/mcp/mcp.json +0 -0
  2. package/.claude/settings.local.json +4 -1
  3. package/.storybook/preview.ts +7 -1
  4. package/.yarn/install-state.gz +0 -0
  5. package/README.md +5 -5
  6. package/dist/{custom-element-BzDjIYMe.js → custom-element-BqBcmDiN.js} +5 -2
  7. package/dist/custom-element-bundle.cjs +1 -1
  8. package/dist/custom-element-bundle.js +2 -2
  9. package/dist/{custom-element-Bssk9jRy.cjs → custom-element-jpOyXHF6.cjs} +1 -1
  10. package/dist/demo/for-each.html +213 -0
  11. package/package.json +4 -4
  12. package/public/demo/for-each.html +213 -0
  13. package/src/custom-element/custom-element.js +3 -0
  14. package/src/custom-element/demo/for-each.html +213 -0
  15. package/src/custom-element/ide/web-types-dce.json +1 -1
  16. package/src/custom-element/ide/web-types-xsl.json +1 -1
  17. package/src/custom-element/index.html +2 -1
  18. package/src/material/theme/colors-native.html +32 -1
  19. package/src/mocks/versions.mock.ts +1 -1
  20. package/src/stories/__screenshots__/http-request.test.ts/http-request-http-request-headers-and-response-status-and-headers-1.png +0 -0
  21. package/src/stories/__screenshots__/http-request.test.ts/http-request-http-request-with-delayed--5-seconds-response-1.png +0 -0
  22. package/src/stories/__screenshots__/http-request.test.ts/http-request-http-request-with-error-1.png +0 -0
  23. package/src/stories/__screenshots__/http-request.test.ts/http-request-url-and-slice-1.png +0 -0
  24. package/src/stories/__screenshots__/http-request.test.ts/http-request-url-change-1.png +0 -0
  25. package/src/stories/__screenshots__/slots.test.stories.ts/slots-slots-TemplateWithAttributesAndCondition-1.png +0 -0
  26. package/src/stories/__screenshots__/xslt-conditionals.test.stories.ts/xslt-conditionals-xslt-conditionals-BooleanAndCondition-1.png +0 -0
  27. package/src/stories/__screenshots__/xslt-conditionals.test.stories.ts/xslt-conditionals-xslt-conditionals-BooleanOrCondition-1.png +0 -0
  28. package/src/stories/__screenshots__/xslt-conditionals.test.stories.ts/xslt-conditionals-xslt-conditionals-ChooseNoAttribute-1.png +0 -0
  29. package/src/stories/__screenshots__/xslt-conditionals.test.stories.ts/xslt-conditionals-xslt-conditionals-ChooseOtherwise-1.png +0 -0
  30. package/src/stories/__screenshots__/xslt-conditionals.test.stories.ts/xslt-conditionals-xslt-conditionals-ChooseSecondWhen-1.png +0 -0
  31. package/src/stories/__screenshots__/xslt-conditionals.test.stories.ts/xslt-conditionals-xslt-conditionals-ChooseWhenOtherwise-1.png +0 -0
  32. package/src/stories/__screenshots__/xslt-conditionals.test.stories.ts/xslt-conditionals-xslt-conditionals-IfFalse-1.png +0 -0
  33. package/src/stories/__screenshots__/xslt-conditionals.test.stories.ts/xslt-conditionals-xslt-conditionals-IfNotExists-1.png +0 -0
  34. package/src/stories/__screenshots__/xslt-conditionals.test.stories.ts/xslt-conditionals-xslt-conditionals-IfTrue-1.png +0 -0
  35. package/src/stories/__screenshots__/xslt-conditionals.test.stories.ts/xslt-conditionals-xslt-conditionals-MultipleIfOrderingIssue-1.png +0 -0
  36. package/src/stories/__screenshots__/xslt-conditionals.test.stories.ts/xslt-conditionals-xslt-conditionals-MultipleInstances-1.png +0 -0
  37. package/src/stories/__screenshots__/xslt-conditionals.test.stories.ts/xslt-conditionals-xslt-conditionals-NestedConditions-1.png +0 -0
  38. package/src/stories/__screenshots__/xslt-conditionals.test.stories.ts/xslt-conditionals-xslt-conditionals-NestedConditionsInactive-1.png +0 -0
  39. package/src/stories/__screenshots__/xslt-conditionals.test.stories.ts/xslt-conditionals-xslt-conditionals-NumericComparison-1.png +0 -0
  40. package/src/stories/__screenshots__/xslt-conditionals.test.stories.ts/xslt-conditionals-xslt-conditionals-NumericComparisonLow-1.png +0 -0
  41. package/src/stories/__screenshots__/xslt-for-each.test.stories.ts/xslt-for-each-xslt-for-each-MultipleIfOrderingIssue-1.png +0 -0
  42. package/src/stories/__screenshots__/xslt-if.test.stories.ts/xslt-if-xslt-if-MultipleIfOrderingIssue-1.png +0 -0
  43. package/src/stories/attributes.test.stories.ts +2 -0
  44. package/src/stories/dom-merge.test.stories.ts +1 -0
  45. package/src/stories/external-template.test.stories.ts +5 -3
  46. package/src/stories/http-request.stories.ts +2 -1
  47. package/src/stories/module-url.test.stories.ts +1 -0
  48. package/src/stories/slice-events.test.stories.ts +3 -0
  49. package/src/stories/xslt-for-each.test.stories.ts +99 -1
  50. package/storybook-static/assets/{Color-F6OSRLHC-DeDlDLjU.js → Color-F6OSRLHC-FZZzFn7T.js} +1 -1
  51. package/storybook-static/assets/{Configure-CH_tIP5N.js → Configure-DyfktOJO.js} +1 -1
  52. package/storybook-static/assets/{DocsRenderer-CFRXHY34-Bc9EPsUI.js → DocsRenderer-CFRXHY34-5isVpCzj.js} +2 -2
  53. package/storybook-static/assets/{attributes.test.stories-BtamFQkF.js → attributes.test.stories-CrDC-RXf.js} +4 -3
  54. package/storybook-static/assets/{css.test.stories-BfNxLgwr.js → css.test.stories-ChWnZJwa.js} +1 -1
  55. package/storybook-static/assets/{custom-element-CnmjNo0g.js → custom-element-wuk8gYiP.js} +1 -1
  56. package/storybook-static/assets/{dom-merge.test.stories-DxnitrLK.js → dom-merge.test.stories-DkarPqD_.js} +2 -2
  57. package/storybook-static/assets/{external-template.test.stories-BTsww7B0.js → external-template.test.stories-DCboR8sG.js} +17 -16
  58. package/storybook-static/assets/{form.test.stories-DNJFtPJb.js → form.test.stories-BjeeUu0b.js} +1 -1
  59. package/storybook-static/assets/handlers-B7UMnC7v.js +291 -0
  60. package/storybook-static/assets/{http-request.stories-DgrBNle8.js → http-request.stories-WIldq1MC.js} +2 -2
  61. package/storybook-static/assets/{iframe-DiVWehoI.js → iframe-CBHPj1E5.js} +2 -2
  62. package/storybook-static/assets/{index-w6iX3YlR.js → index-BL0FQnAE.js} +3 -3
  63. package/storybook-static/assets/{index-CdEbhcV9.js → index-CzwPLrca.js} +1 -1
  64. package/storybook-static/assets/{local-storage.test.stories-Hwq80yUr.js → local-storage.test.stories-DLMK0p2s.js} +1 -1
  65. package/storybook-static/assets/{location-element.test.stories-mEhZzm7x.js → location-element.test.stories-BroqoLMS.js} +1 -1
  66. package/storybook-static/assets/{module-url.test.stories-Bj46iT0V.js → module-url.test.stories-B-0dibET.js} +2 -2
  67. package/storybook-static/assets/{preview-BjbXcJci.js → preview-BG24UPL5.js} +2 -2
  68. package/storybook-static/assets/preview-C1KnQPMW.js +50 -0
  69. package/storybook-static/assets/{set-url.test.stories-hzxLcqmm.js → set-url.test.stories-Dhq4YQyr.js} +1 -1
  70. package/storybook-static/assets/{slice-events.test.stories-DVyXFRU1.js → slice-events.test.stories-BZJGIFku.js} +17 -15
  71. package/storybook-static/assets/{slots.test.stories-CS544nS4.js → slots.test.stories-DKivHwZH.js} +1 -1
  72. package/storybook-static/assets/{version-select.test.stories-D36nfYBq.js → version-select.test.stories-Dntyd7qb.js} +1 -1
  73. package/storybook-static/assets/{xslt-conditionals.test.stories-BS1PTIHe.js → xslt-conditionals.test.stories-Iq5iQNRj.js} +1 -1
  74. package/storybook-static/assets/{xslt-for-each.test.stories-CtPS20RK.js → xslt-for-each.test.stories-BMygBmj8.js} +132 -12
  75. package/storybook-static/assets/{xslt-if.test.stories-DcHrAMSY.js → xslt-if.test.stories-CVrFWdAX.js} +1 -1
  76. package/storybook-static/demo/for-each.html +213 -0
  77. package/storybook-static/iframe.html +1 -1
  78. package/storybook-static/index.json +1 -1
  79. package/storybook-static/project.json +1 -1
  80. package/vite.config.js +2 -1
  81. package/coverage/base.css +0 -224
  82. package/coverage/block-navigation.js +0 -87
  83. package/coverage/coverage-final.json +0 -12
  84. package/coverage/favicon.png +0 -0
  85. package/coverage/index.html +0 -176
  86. package/coverage/prettify.css +0 -1
  87. package/coverage/prettify.js +0 -2
  88. package/coverage/sort-arrow-sprite.png +0 -0
  89. package/coverage/sorter.js +0 -210
  90. package/coverage/src/coverage.svg +0 -10
  91. package/coverage/src/custom-element/coverage.svg +0 -10
  92. package/coverage/src/custom-element/custom-element.js/coverage.svg +0 -10
  93. package/coverage/src/custom-element/custom-element.js.html +0 -3034
  94. package/coverage/src/custom-element/http-request.js/coverage.svg +0 -10
  95. package/coverage/src/custom-element/http-request.js.html +0 -373
  96. package/coverage/src/custom-element/index.html +0 -176
  97. package/coverage/src/custom-element/local-storage.js/coverage.svg +0 -10
  98. package/coverage/src/custom-element/local-storage.js.html +0 -361
  99. package/coverage/src/custom-element/location-element.js/coverage.svg +0 -10
  100. package/coverage/src/custom-element/location-element.js.html +0 -412
  101. package/coverage/src/custom-element/module-url.js/coverage.svg +0 -10
  102. package/coverage/src/custom-element/module-url.js.html +0 -187
  103. package/coverage/src/index.html +0 -116
  104. package/coverage/src/material/theme/colors.js/coverage.svg +0 -10
  105. package/coverage/src/material/theme/colors.js.html +0 -217
  106. package/coverage/src/material/theme/coverage.svg +0 -10
  107. package/coverage/src/material/theme/index.html +0 -116
  108. package/coverage/src/mocks/coverage.svg +0 -10
  109. package/coverage/src/mocks/handlers.ts/coverage.svg +0 -10
  110. package/coverage/src/mocks/handlers.ts.html +0 -196
  111. package/coverage/src/mocks/index.html +0 -116
  112. package/coverage/src/stories/coverage.svg +0 -10
  113. package/coverage/src/stories/frame.canvas.ts/coverage.svg +0 -10
  114. package/coverage/src/stories/frame.canvas.ts.html +0 -175
  115. package/coverage/src/stories/http-request.stories.ts/coverage.svg +0 -10
  116. package/coverage/src/stories/http-request.stories.ts.html +0 -817
  117. package/coverage/src/stories/index.html +0 -146
  118. package/coverage/src/stories/testStoryBook.ts/coverage.svg +0 -10
  119. package/coverage/src/stories/testStoryBook.ts.html +0 -169
  120. package/coverage/src/sum.ts/coverage.svg +0 -10
  121. package/coverage/src/sum.ts.html +0 -94
  122. package/storybook-static/assets/handlers-Dvg8CAeR.js +0 -470
  123. package/storybook-static/assets/preview-CfuT8gak.js +0 -50
@@ -1,9 +1,9 @@
1
- import{w as n,e as t,u as s}from"./index-CGuyH0k-.js";import"./custom-element-CnmjNo0g.js";function l(a){return new Promise(e=>setTimeout(e,a))}function B(a){const{title:e,body:c}=a;return`
1
+ import{w as s,e as t,u as n}from"./index-CGuyH0k-.js";import"./custom-element-wuk8gYiP.js";function l(a){return new Promise(e=>setTimeout(e,a))}function g(a){const{title:e,body:c}=a;return`
2
2
  <fieldset>
3
3
  <legend>${e}</legend>
4
4
  ${c}
5
5
  </fieldset>
6
- `}const C={title:"slice-events",render:B},u={args:{title:"Slice initialization, change on event",body:`
6
+ `}const C={title:"slice-events",render:g},u={args:{title:"Slice initialization, change on event",body:`
7
7
  <p>initial value should be 0; + and - should change the number in input field</p>
8
8
  <custom-element>
9
9
  <template>
@@ -13,7 +13,7 @@ import{w as n,e as t,u as s}from"./index-CGuyH0k-.js";import"./custom-element-Cn
13
13
  <code data-testid="slice-value">{ //clickcount }</code>
14
14
  </template>
15
15
  </custom-element>
16
- `},play:async({canvasElement:a})=>{const e=u.args.title,c=n(a);await c.findByText(e);const i=await c.findByTestId("slice-value"),o=await a.querySelector('[type="number"]');await t(i).toBeInTheDocument(),t(i.textContent).to.equal("0","initial slot value 0"),t(o.value).to.equal("0","initial input value 0"),a.querySelector('[slice-value="//clickcount + 1"]').click(),await l(10),t(i.textContent).to.equal("1","increment to 1"),t(o.value).to.equal("1","increment input 1"),a.querySelector('[slice-value="//clickcount + 1"]').click(),await l(10),a.querySelector('[slice-value="//clickcount + 1"]').click(),await l(10),t(i.textContent).to.equal("3","double increment to 3"),t(o.value).to.equal("3","double increment input to 3"),a.querySelector('[slice-value="//clickcount - 1"]').click(),await l(10),t(i.textContent).to.equal("2","decrement to 2"),t(o.value).to.equal("2","decrement input to 2")}},p={args:{title:"Realtime Slice data on event",body:`
16
+ `},play:async({canvasElement:a})=>{const e=u.args.title,c=s(a);await c.findByText(e);const i=await c.findByTestId("slice-value"),o=await a.querySelector('[type="number"]');await t(i).toBeInTheDocument(),t(i.textContent).to.equal("0","initial slot value 0"),t(o.value).to.equal("0","initial input value 0"),a.querySelector('[slice-value="//clickcount + 1"]').click(),await l(10),t(i.textContent).to.equal("1","increment to 1"),t(o.value).to.equal("1","increment input 1"),a.querySelector('[slice-value="//clickcount + 1"]').click(),await l(10),a.querySelector('[slice-value="//clickcount + 1"]').click(),await l(10),t(i.textContent).to.equal("3","double increment to 3"),t(o.value).to.equal("3","double increment input to 3"),a.querySelector('[slice-value="//clickcount - 1"]').click(),await l(10),t(i.textContent).to.equal("2","decrement to 2"),t(o.value).to.equal("2","decrement input to 2")}},p={args:{title:"Realtime Slice data on event",body:`
17
17
  <p>move the mouse over TEXTAREA and click to see slice and slice event changed</p>
18
18
  <custom-element>
19
19
  <template>
@@ -24,7 +24,7 @@ import{w as n,e as t,u as s}from"./index-CGuyH0k-.js";import"./custom-element-Cn
24
24
  event type : <code data-testid="//slice/s/event/@type" >{ //slice/s/event/@type }</code>
25
25
  </template>
26
26
  </custom-element>
27
- `},play:async({canvasElement:a})=>{const e=p.args.title,c=n(a);await c.findByText(e);const i=()=>c.getByTestId("//slice/s").textContent,o=()=>c.getByTestId("//slice/s/event/@offsetY").textContent,w=()=>c.getByTestId("//slice/s/event/@type").textContent,k=await a.querySelector("textarea");t(i()).to.equal("","initial slot value blank"),t(o()).to.equal("","initial slot offsetY blank"),t(w()).to.equal("","initial slot event blank"),((h,x,T)=>{const g=new MouseEvent(T,{screenX:h,screenY:x,clientX:h,clientY:x,offsetX:h,offsetY:x});k.dispatchEvent(g)})(20,20,"click"),await l(10),t(i()).to.equal("x:20","click slot value 20"),t(Number(o())).to.be.lessThan(0,"offsetY click"),t(w()).to.equal("click","click event type")}},d={args:{title:'slice-event="change submit change submit" ',body:`
27
+ `},play:async({canvasElement:a})=>{const e=p.args.title,c=s(a);await c.findByText(e);const i=()=>c.getByTestId("//slice/s").textContent,o=()=>c.getByTestId("//slice/s/event/@offsetY").textContent,x=()=>c.getByTestId("//slice/s/event/@type").textContent,k=await a.querySelector("textarea");t(i()).to.equal("","initial slot value blank"),t(o()).to.equal("","initial slot offsetY blank"),t(x()).to.equal("","initial slot event blank"),((h,w,T)=>{const B=new MouseEvent(T,{screenX:h,screenY:w,clientX:h,clientY:w,offsetX:h,offsetY:w});k.dispatchEvent(B)})(20,20,"click"),await l(10),t(i()).to.equal("x:20","click slot value 20"),t(Number(o())).to.be.lessThan(0,"offsetY click"),t(x()).to.equal("click","click event type")}},d={args:{title:'slice-event="change submit change submit" ',body:`
28
28
  <p> double same event should be treated as one.</p>
29
29
  <custom-element>
30
30
  <template>
@@ -35,7 +35,7 @@ import{w as n,e as t,u as s}from"./index-CGuyH0k-.js";import"./custom-element-Cn
35
35
  </form>
36
36
  </template>
37
37
  </custom-element>
38
- `},play:async({canvasElement:a})=>{const e=n(a),c=await e.findByTestId("f1");c.focus(),await s.type(c,"AB"),e.getByRole("button").focus(),await s.clear(c),await s.click(e.getByRole("button")),t(await e.findByText("slices count 2")).toBeInTheDocument()}},r={args:{title:'slice="/datadom/attributes/emotion | s1" ',body:`
38
+ `},play:async({canvasElement:a})=>{const e=s(a),c=await e.findByTestId("f1");c.focus(),await n.type(c,"AB"),e.getByRole("button").focus(),await n.clear(c),await n.click(e.getByRole("button")),t(await e.findByText("slices count 2")).toBeInTheDocument()}},m={args:{title:'slice="/datadom/attributes/emotion | s1" ',body:`
39
39
  <p> double same event should be treated as one.</p>
40
40
  <custom-element>
41
41
  <template>
@@ -48,7 +48,7 @@ import{w as n,e as t,u as s}from"./index-CGuyH0k-.js";import"./custom-element-Cn
48
48
  slice <code>s2: {//slice/s2}</code><br/>
49
49
  </template>
50
50
  </custom-element>
51
- `},play:async({canvasElement:a})=>{const e=n(a),c=await e.findByTestId("f1");c.focus(),await s.type(c,"AB"),await t(await e.findByText("s1: AB")).toBeInTheDocument(),await t(await e.findByText("s2: AB")).toBeInTheDocument()}},m={args:{title:'slice="/datadom/attributes/emotion | s1" ',body:`
51
+ `},play:async({canvasElement:a})=>{const e=s(a),c=await e.findByTestId("f1");c.focus(),await n.type(c,"AB"),await t(await e.findByText("s1: AB")).toBeInTheDocument(),await t(await e.findByText("s2: AB")).toBeInTheDocument()}},r={args:{title:'slice="/datadom/attributes/emotion | s1" ',body:`
52
52
  <p> double same event should be treated as one.</p>
53
53
  <custom-element>
54
54
  <template>
@@ -59,7 +59,7 @@ import{w as n,e as t,u as s}from"./index-CGuyH0k-.js";import"./custom-element-Cn
59
59
  <p>slice: {//slice/s1}</p>
60
60
  </template>
61
61
  </custom-element>
62
- `},play:async({canvasElement:a})=>{const e=n(a),c=await e.findByTestId("f1");c.focus(),await s.type(c,"AB"),await t(await e.findByText("emotion attribute: AB")).toBeInTheDocument()}},v={args:{title:"Checkbox value in slice ",body:`
62
+ `},play:async({canvasElement:a})=>{const e=s(a),c=await e.findByTestId("f1");c.focus(),await n.type(c,"AB"),await t(await e.findByText("emotion attribute: AB")).toBeInTheDocument()}},v={args:{title:"Checkbox value in slice ",body:`
63
63
  <p> Checked value propagated into slice</p>
64
64
  <custom-element>
65
65
  <template>
@@ -67,7 +67,7 @@ import{w as n,e as t,u as s}from"./index-CGuyH0k-.js";import"./custom-element-Cn
67
67
  <p>slice: {//s1}</p>
68
68
  </template>
69
69
  </custom-element>
70
- `},play:async({canvasElement:a})=>{const e=n(a);await t(await e.findByText("slice: V1")).toBeInTheDocument()}},y={args:{title:"UncheckedCheckbox value not in slice ",body:`
70
+ `},play:async({canvasElement:a})=>{const e=s(a);await t(await e.findByText("slice: V1")).toBeInTheDocument()}},y={args:{title:"UncheckedCheckbox value not in slice ",body:`
71
71
  <p> Check to see the value propagated into slice. Uncheck to observe the empty string in the slice. </p>
72
72
  <custom-element>
73
73
  <template>
@@ -75,7 +75,7 @@ import{w as n,e as t,u as s}from"./index-CGuyH0k-.js";import"./custom-element-Cn
75
75
  <p data-testid="t1">slice: {//s1}</p>
76
76
  </template>
77
77
  </custom-element>
78
- `},play:async({canvasElement:a})=>{const e=n(a),c=await e.findByTestId("t1");await t(c.textContent).toEqual("slice: ");const i=await e.findByTestId("i1");await s.click(i),await t(await e.findByText("slice: V1")).toBeInTheDocument(),await s.click(i),await t(c.textContent).toEqual("slice: ")}},b={args:{title:"UncheckedCheckbox slice-value not in slice ",body:`
78
+ `},play:async({canvasElement:a})=>{const e=s(a),c=await e.findByTestId("t1");await t(c.textContent).toEqual("slice: ");const i=await e.findByTestId("i1");await n.click(i),await t(await e.findByText("slice: V1")).toBeInTheDocument(),await n.click(i),await t(await e.findByText("slice:")).toBeInTheDocument(),await t(c.textContent).toEqual("slice: ")}},b={args:{title:"UncheckedCheckbox slice-value not in slice ",body:`
79
79
  <p> Check to see the value propagated into slice. Uncheck to observe the empty string in the slice. </p>
80
80
  <custom-element>
81
81
  <template>
@@ -83,7 +83,7 @@ import{w as n,e as t,u as s}from"./index-CGuyH0k-.js";import"./custom-element-Cn
83
83
  <p data-testid="t1">slice: {//s1}</p>
84
84
  </template>
85
85
  </custom-element>
86
- `},play:async({canvasElement:a})=>{const e=n(a),c=await e.findByTestId("t1");await t(c.textContent).toEqual("slice: ");const i=await e.findByTestId("i1");await s.click(i),await t(await e.findByText("slice: V1")).toBeInTheDocument(),await s.click(i),await t(c.textContent).toEqual("slice: ")}},f={args:{title:"Radiogroup value",body:`
86
+ `},play:async({canvasElement:a})=>{const e=s(a),c=await e.findByTestId("t1");await t(c.textContent).toEqual("slice: ");const i=await e.findByTestId("i1");await n.click(i),await t(await e.findByText("slice: V1")).toBeInTheDocument(),await n.click(i),await t(await e.findByText("slice:")).toBeInTheDocument(),await t(c.textContent).toEqual("slice: ")}},f={args:{title:"Radiogroup value",body:`
87
87
  <p> The value propagated into slice from the last checked radiobutton. </p>
88
88
  <custom-element>
89
89
  <template>
@@ -92,7 +92,7 @@ import{w as n,e as t,u as s}from"./index-CGuyH0k-.js";import"./custom-element-Cn
92
92
  <p data-testid="t1">slice: {//s1}</p>
93
93
  </template>
94
94
  </custom-element>
95
- `},play:async({canvasElement:a})=>{const e=n(a);await s.click(await e.findByTestId("i1")),await t(await e.findByText("slice: V1")).toBeInTheDocument(),await s.click(await e.findByTestId("i2")),await t(await e.findByText("slice: V2")).toBeInTheDocument()}};u.parameters={...u.parameters,docs:{...u.parameters?.docs,source:{originalSource:`{
95
+ `},play:async({canvasElement:a})=>{const e=s(a);await n.click(await e.findByTestId("i1")),await t(await e.findByText("slice: V1")).toBeInTheDocument(),await n.click(await e.findByTestId("i2")),await t(await e.findByText("slice: V2")).toBeInTheDocument()}};u.parameters={...u.parameters,docs:{...u.parameters?.docs,source:{originalSource:`{
96
96
  args: {
97
97
  title: 'Slice initialization, change on event',
98
98
  body: \`
@@ -208,7 +208,7 @@ import{w as n,e as t,u as s}from"./index-CGuyH0k-.js";import"./custom-element-Cn
208
208
  await userEvent.click(canvas.getByRole('button'));
209
209
  expect(await canvas.findByText('slices count 2')).toBeInTheDocument();
210
210
  }
211
- }`,...d.parameters?.docs?.source}}};r.parameters={...r.parameters,docs:{...r.parameters?.docs,source:{originalSource:`{
211
+ }`,...d.parameters?.docs?.source}}};m.parameters={...m.parameters,docs:{...m.parameters?.docs,source:{originalSource:`{
212
212
  args: {
213
213
  title: 'slice="/datadom/attributes/emotion | s1" ',
214
214
  body: \`
@@ -236,7 +236,7 @@ import{w as n,e as t,u as s}from"./index-CGuyH0k-.js";import"./custom-element-Cn
236
236
  await expect(await canvas.findByText('s1: AB')).toBeInTheDocument();
237
237
  await expect(await canvas.findByText('s2: AB')).toBeInTheDocument();
238
238
  }
239
- }`,...r.parameters?.docs?.source}}};m.parameters={...m.parameters,docs:{...m.parameters?.docs,source:{originalSource:`{
239
+ }`,...m.parameters?.docs?.source}}};r.parameters={...r.parameters,docs:{...r.parameters?.docs,source:{originalSource:`{
240
240
  args: {
241
241
  title: 'slice="/datadom/attributes/emotion | s1" ',
242
242
  body: \`
@@ -261,7 +261,7 @@ import{w as n,e as t,u as s}from"./index-CGuyH0k-.js";import"./custom-element-Cn
261
261
  await userEvent.type(input, 'AB');
262
262
  await expect(await canvas.findByText('emotion attribute: AB')).toBeInTheDocument();
263
263
  }
264
- }`,...m.parameters?.docs?.source}}};v.parameters={...v.parameters,docs:{...v.parameters?.docs,source:{originalSource:`{
264
+ }`,...r.parameters?.docs?.source}}};v.parameters={...v.parameters,docs:{...v.parameters?.docs,source:{originalSource:`{
265
265
  args: {
266
266
  title: 'Checkbox value in slice ',
267
267
  body: \`
@@ -303,6 +303,7 @@ import{w as n,e as t,u as s}from"./index-CGuyH0k-.js";import"./custom-element-Cn
303
303
  await userEvent.click(cb);
304
304
  await expect(await canvas.findByText('slice: V1')).toBeInTheDocument();
305
305
  await userEvent.click(cb);
306
+ await expect(await canvas.findByText('slice:')).toBeInTheDocument();
306
307
  await expect(p.textContent).toEqual('slice: ');
307
308
  }
308
309
  }`,...y.parameters?.docs?.source}}};b.parameters={...b.parameters,docs:{...b.parameters?.docs,source:{originalSource:`{
@@ -328,6 +329,7 @@ import{w as n,e as t,u as s}from"./index-CGuyH0k-.js";import"./custom-element-Cn
328
329
  await userEvent.click(cb);
329
330
  await expect(await canvas.findByText('slice: V1')).toBeInTheDocument();
330
331
  await userEvent.click(cb);
332
+ await expect(await canvas.findByText('slice:')).toBeInTheDocument();
331
333
  await expect(p.textContent).toEqual('slice: ');
332
334
  }
333
335
  }`,...b.parameters?.docs?.source}}};f.parameters={...f.parameters,docs:{...f.parameters?.docs,source:{originalSource:`{
@@ -353,4 +355,4 @@ import{w as n,e as t,u as s}from"./index-CGuyH0k-.js";import"./custom-element-Cn
353
355
  await userEvent.click(await canvas.findByTestId('i2'));
354
356
  await expect(await canvas.findByText('slice: V2')).toBeInTheDocument();
355
357
  }
356
- }`,...f.parameters?.docs?.source}}};const S=["SliceInitChangeEvent","RealtimeEventInSlice","DoubleEventInSlice","MultipleSlices","SlicesInAttrAndName","CheckboxChecked","CheckboxUnchecked","CheckboxSliceValue","RadiogroupSliceValue"];export{v as CheckboxChecked,b as CheckboxSliceValue,y as CheckboxUnchecked,d as DoubleEventInSlice,r as MultipleSlices,f as RadiogroupSliceValue,p as RealtimeEventInSlice,u as SliceInitChangeEvent,m as SlicesInAttrAndName,S as __namedExportsOrder,C as default};
358
+ }`,...f.parameters?.docs?.source}}};const S=["SliceInitChangeEvent","RealtimeEventInSlice","DoubleEventInSlice","MultipleSlices","SlicesInAttrAndName","CheckboxChecked","CheckboxUnchecked","CheckboxSliceValue","RadiogroupSliceValue"];export{v as CheckboxChecked,b as CheckboxSliceValue,y as CheckboxUnchecked,d as DoubleEventInSlice,m as MultipleSlices,f as RadiogroupSliceValue,p as RealtimeEventInSlice,u as SliceInitChangeEvent,r as SlicesInAttrAndName,S as __namedExportsOrder,C as default};
@@ -1,4 +1,4 @@
1
- import{w as o,e as l}from"./index-CGuyH0k-.js";import"./custom-element-CnmjNo0g.js";function y(t){const{title:a,tag:n,attributes:e,slot:s,payload:g}=t;return`
1
+ import{w as o,e as l}from"./index-CGuyH0k-.js";import"./custom-element-wuk8gYiP.js";function y(t){const{title:a,tag:n,attributes:e,slot:s,payload:g}=t;return`
2
2
  <fieldset>
3
3
  <legend>${a}</legend>
4
4
  <custom-element
@@ -1,4 +1,4 @@
1
- import{w as r}from"./index-CGuyH0k-.js";import"./custom-element-CnmjNo0g.js";import"./http-request-BWeEEBkP.js";import"./location-element-hKpcXCdn.js";function o(e){return new Promise(s=>setTimeout(s,e))}function n(e){const{title:s,body:i}=e;return`
1
+ import{w as r}from"./index-CGuyH0k-.js";import"./custom-element-wuk8gYiP.js";import"./http-request-BWeEEBkP.js";import"./location-element-hKpcXCdn.js";function o(e){return new Promise(s=>setTimeout(s,e))}function n(e){const{title:s,body:i}=e;return`
2
2
  <fieldset>
3
3
  <legend>${s}</legend>
4
4
  ${i}
@@ -1,4 +1,4 @@
1
- import{w as n,e,u as I}from"./index-CGuyH0k-.js";import"./custom-element-CnmjNo0g.js";function o(a){return new Promise(s=>setTimeout(s,a))}function B(a){const{title:s,tag:t,template:i,payload:r}=a;return`
1
+ import{w as n,e,u as I}from"./index-CGuyH0k-.js";import"./custom-element-wuk8gYiP.js";function o(a){return new Promise(s=>setTimeout(s,a))}function B(a){const{title:s,tag:t,template:i,payload:r}=a;return`
2
2
  <fieldset>
3
3
  <legend>${s}</legend>
4
4
  <custom-element tag="${t}" hidden>
@@ -1,14 +1,14 @@
1
- import{w as r,e,f as s}from"./index-CGuyH0k-.js";import"./custom-element-CnmjNo0g.js";function m(d){const{title:t,tag:a,template:n,payload:i}=d;return`
1
+ import{w as i,e,f as m}from"./index-CGuyH0k-.js";import"./custom-element-wuk8gYiP.js";function w(a){const{title:t,tag:d,template:o,payload:s}=a;return`
2
2
  <fieldset>
3
3
  <legend>${t}</legend>
4
- <custom-element tag="${a}" hidden>
4
+ <custom-element tag="${d}" hidden>
5
5
  <template>
6
- ${n}
6
+ ${o}
7
7
  </template>
8
8
  </custom-element>
9
- ${i}
9
+ ${s}
10
10
  </fieldset>
11
- `}const u={title:"xslt/for-each",render:m},l=`
11
+ `}const y={title:"xslt/for-each",render:w,parameters:{test:{dangerouslyIgnoreUnhandledErrors:!0}}},x=`
12
12
  <h6 id="cem-color-hue-variant" tabindex="-1">cem-color-hue-variant</h6>
13
13
  <table>
14
14
  <thead>
@@ -231,9 +231,9 @@ import{w as r,e,f as s}from"./index-CGuyH0k-.js";import"./custom-element-CnmjNo0
231
231
  <td>Danger palette (dark theme, extreme)</td>
232
232
  </tr>
233
233
  </tbody>
234
- </table>`,o={args:{title:"KNOWN ISSUE: Multiple IF blocks - out of order",tag:"multi-for-each",template:`
234
+ </table>`,l={args:{title:"KNOWN ISSUE: Multiple IF blocks - out of order",tag:"multi-for-each",template:`
235
235
  <div data-testid="whole-text">
236
- <xsl:variable name="test-data">${l}</xsl:variable>
236
+ <xsl:variable name="test-data">${x}</xsl:variable>
237
237
  <hr/>
238
238
  <variable name="cem-color-hue-variant" select="exsl:node-set($test-data)//*[@id='cem-color-hue-variant']/following-sibling::table[1]/tbody"></variable>
239
239
  <for-each select="$cem-color-hue-variant/*">
@@ -244,9 +244,9 @@ import{w as r,e,f as s}from"./index-CGuyH0k-.js";import"./custom-element-CnmjNo0
244
244
 
245
245
  `,payload:`
246
246
  <multi-for-each></multi-for-each>
247
- `},play:async({canvasElement:d})=>{const t=r(d);e(await await t.findByTestId("color-1")).toBeInTheDocument(),e(await await t.findByText("--cem-color-blue-l")).toBeInTheDocument(),e(await await t.findByTestId("color-26")).toBeInTheDocument(),e(await await t.findByText("--cem-color-red-xd")).toBeInTheDocument()}},c={args:{title:"initially none, on check - all items in order 0 to N. N should be in the end",tag:"for-each-0-to-n",template:`
247
+ `},play:async({canvasElement:a})=>{const t=i(a);e(await await t.findByTestId("color-1")).toBeInTheDocument(),e(await await t.findByText("--cem-color-blue-l")).toBeInTheDocument(),e(await await t.findByTestId("color-26")).toBeInTheDocument(),e(await await t.findByText("--cem-color-red-xd")).toBeInTheDocument()}},c={args:{title:"initially none, on check - all items in order 0 to N. N should be in the end",tag:"for-each-0-to-n",template:`
248
248
  <div data-testid="whole-text">
249
- <xsl:variable name="test-data">${l}</xsl:variable>
249
+ <xsl:variable name="test-data">${x}</xsl:variable>
250
250
  <label><input type="checkbox" data-testid="toggle-all" slice="show-all" value="ALL" /> ALL </label>
251
251
  <variable name="cem-color-hue-variant" select="exsl:node-set($test-data)//*[@id='cem-color-hue-variant']/following-sibling::table[1]/tbody"></variable>
252
252
  <variable name="show-all" select="//show-all = 'ALL'"></variable>
@@ -261,7 +261,46 @@ import{w as r,e,f as s}from"./index-CGuyH0k-.js";import"./custom-element-CnmjNo0
261
261
 
262
262
  `,payload:`
263
263
  <for-each-0-to-n></for-each-0-to-n>
264
- `},play:async({canvasElement:d})=>{const t=r(d),a=await t.findByTestId("whole-text");await e(a.textContent).toMatch(/0\s+N/),await s.click(await t.findByTestId("toggle-all")),await t.findByText("1--cem-color-blue-xl"),await e(await t.findByText("1--cem-color-blue-xl")).toBeInTheDocument(),await e(a.textContent).toMatch(/0\s+1--cem-color-blue-xl[\s\S]*26--cem-color-red-xd\s+N/)}};o.parameters={...o.parameters,docs:{...o.parameters?.docs,source:{originalSource:`{
264
+ `},play:async({canvasElement:a})=>{const t=i(a),d=await t.findByTestId("whole-text");await e(d.textContent).toMatch(/0\s+N/),await m.click(await t.findByTestId("toggle-all")),await t.findByText("1--cem-color-blue-xl"),await e(await t.findByText("1--cem-color-blue-xl")).toBeInTheDocument(),await e(d.textContent).toMatch(/0\s+1--cem-color-blue-xl[\s\S]*26--cem-color-red-xd\s+N/)}},T=`
265
+ <rows>
266
+ <r id="1"><d>A1</d><d>A2</d><d>A3</d></r>
267
+ <r id="2"><d>B1</d><d>B2</d><d>B3</d></r>
268
+ <r id="3"><d>C1</d><d>C2</d><d>C3</d></r>
269
+ </rows>`,n={args:{title:"Table 3x3: initially empty, rows shown by checkbox, content stays inside table",tag:"for-each-table-3x3",template:`
270
+ <xsl:variable name="rows-data">${T}</xsl:variable>
271
+ <variable name="rows" select="exsl:node-set($rows-data)/*/*"></variable>
272
+ <label><input type="checkbox" data-testid="toggle-rows" slice="show-rows" value="yes" /> Show rows</label>
273
+ <variable name="show-rows" select="//show-rows = 'yes'"></variable>
274
+ <pre data-testid="just-text">
275
+ JUST_TEXT_BEFORE
276
+ <for-each select="$rows[$show-rows]">
277
+ <for-each select="*">
278
+ {.} #
279
+ </for-each>
280
+ </for-each>
281
+ JUST_TEXT_AFTER
282
+ </pre>
283
+ <div data-testid="container">
284
+ TEXT_BEFORE
285
+ <xhtml:table data-testid="the-table">
286
+ <xhtml:thead>
287
+ <xhtml:tr><xhtml:th>Col A</xhtml:th><xhtml:th>Col B</xhtml:th><xhtml:th>Col C</xhtml:th></xhtml:tr>
288
+ </xhtml:thead>
289
+ <xhtml:tbody data-testid="table-body">
290
+ <for-each select="$rows[$show-rows]">
291
+ <xhtml:tr data-testid="row-{@id}">
292
+ <for-each select="*">
293
+ <xhtml:td>{.}</xhtml:td>
294
+ </for-each>
295
+ </xhtml:tr>
296
+ </for-each>
297
+ </xhtml:tbody>
298
+ </xhtml:table>
299
+ TEXT_AFTER
300
+ </div>
301
+ `,payload:`
302
+ <for-each-table-3x3></for-each-table-3x3>
303
+ `},play:async({canvasElement:a})=>{const t=i(a),d=await t.findByTestId("just-text");e(d.textContent).toMatch(/JUST_TEXT_BEFORE[\s\S]*JUST_TEXT_AFTER/);const o=await t.findByTestId("container"),s=await t.findByTestId("the-table"),r=await t.findByTestId("table-body");e(r.querySelectorAll("tr").length).toBe(0),e(o.textContent).toMatch(/TEXT_BEFORE[\s\S]*Col A[\s\S]*TEXT_AFTER/),await m.click(await t.findByTestId("toggle-rows")),e(await t.findByTestId("row-1")).toBeInTheDocument(),e(await t.findByTestId("row-2")).toBeInTheDocument(),e(await t.findByTestId("row-3")).toBeInTheDocument(),e(r.querySelectorAll("tr").length).toBe(3),e(d.textContent).toMatch(/JUST_TEXT_BEFORE[\s\S]*A1 #/),e(d.textContent).toMatch(/C3 #[\s\S]*JUST_TEXT_AFTER/),r.querySelectorAll("tr").forEach(b=>{e(b.parentElement).toBe(r)}),e(o.textContent).toMatch(/TEXT_BEFORE[\s\S]*?Col A[\s\S]*?Col B[\s\S]*?Col C[\s\S]*?A1[\s\S]*?A2[\s\S]*?A3[\s\S]*?B1[\s\S]*?B2[\s\S]*?B3[\s\S]*?C1[\s\S]*?C2[\s\S]*?C3[\s\S]*?TEXT_AFTER/);const h=s.outerHTML;e(h).toContain("A1"),e(h).toContain("C3")}};l.parameters={...l.parameters,docs:{...l.parameters?.docs,source:{originalSource:`{
265
304
  args: {
266
305
  title: 'KNOWN ISSUE: Multiple IF blocks - out of order',
267
306
  tag: 'multi-for-each',
@@ -290,7 +329,7 @@ import{w as r,e,f as s}from"./index-CGuyH0k-.js";import"./custom-element-CnmjNo0
290
329
  expect(await await canvas.findByTestId('color-26')).toBeInTheDocument();
291
330
  expect(await await canvas.findByText('--cem-color-red-xd')).toBeInTheDocument();
292
331
  }
293
- }`,...o.parameters?.docs?.source}}};c.parameters={...c.parameters,docs:{...c.parameters?.docs,source:{originalSource:`{
332
+ }`,...l.parameters?.docs?.source}}};c.parameters={...c.parameters,docs:{...c.parameters?.docs,source:{originalSource:`{
294
333
  args: {
295
334
  title: 'initially none, on check - all items in order 0 to N. N should be in the end',
296
335
  tag: 'for-each-0-to-n',
@@ -326,4 +365,85 @@ import{w as r,e,f as s}from"./index-CGuyH0k-.js";import"./custom-element-CnmjNo0
326
365
  // should start with 0 and end with N
327
366
  await expect(container.textContent).toMatch(/0\\s+1--cem-color-blue-xl[\\s\\S]*26--cem-color-red-xd\\s+N/);
328
367
  }
329
- }`,...c.parameters?.docs?.source}}};const x=["ForEach","ForEach_0_2_N"];export{o as ForEach,c as ForEach_0_2_N,x as __namedExportsOrder,u as default};
368
+ }`,...c.parameters?.docs?.source}}};n.parameters={...n.parameters,docs:{...n.parameters?.docs,source:{originalSource:`{
369
+ args: {
370
+ title: 'Table 3x3: initially empty, rows shown by checkbox, content stays inside table',
371
+ tag: 'for-each-table-3x3',
372
+ template: \`
373
+ <xsl:variable name="rows-data">\${Table3x3Data}</xsl:variable>
374
+ <variable name="rows" select="exsl:node-set($rows-data)/*/*"></variable>
375
+ <label><input type="checkbox" data-testid="toggle-rows" slice="show-rows" value="yes" /> Show rows</label>
376
+ <variable name="show-rows" select="//show-rows = 'yes'"></variable>
377
+ <pre data-testid="just-text">
378
+ JUST_TEXT_BEFORE
379
+ <for-each select="$rows[$show-rows]">
380
+ <for-each select="*">
381
+ {.} #
382
+ </for-each>
383
+ </for-each>
384
+ JUST_TEXT_AFTER
385
+ </pre>
386
+ <div data-testid="container">
387
+ TEXT_BEFORE
388
+ <xhtml:table data-testid="the-table">
389
+ <xhtml:thead>
390
+ <xhtml:tr><xhtml:th>Col A</xhtml:th><xhtml:th>Col B</xhtml:th><xhtml:th>Col C</xhtml:th></xhtml:tr>
391
+ </xhtml:thead>
392
+ <xhtml:tbody data-testid="table-body">
393
+ <for-each select="$rows[$show-rows]">
394
+ <xhtml:tr data-testid="row-{@id}">
395
+ <for-each select="*">
396
+ <xhtml:td>{.}</xhtml:td>
397
+ </for-each>
398
+ </xhtml:tr>
399
+ </for-each>
400
+ </xhtml:tbody>
401
+ </xhtml:table>
402
+ TEXT_AFTER
403
+ </div>
404
+ \`,
405
+ payload: \`
406
+ <for-each-table-3x3></for-each-table-3x3>
407
+ \`
408
+ },
409
+ play: async ({
410
+ canvasElement
411
+ }) => {
412
+ const canvas = within(canvasElement);
413
+ const justTextContainer = await canvas.findByTestId('just-text');
414
+ expect(justTextContainer.textContent).toMatch(/JUST_TEXT_BEFORE[\\s\\S]*JUST_TEXT_AFTER/);
415
+ const container = await canvas.findByTestId('container');
416
+ const table = await canvas.findByTestId('the-table');
417
+ const tbody = await canvas.findByTestId('table-body');
418
+
419
+ // Initially no rows visible
420
+ expect(tbody.querySelectorAll('tr').length).toBe(0);
421
+ // TEXT_BEFORE ... TEXT_AFTER with table in between (but no row content)
422
+ expect(container.textContent).toMatch(/TEXT_BEFORE[\\s\\S]*Col A[\\s\\S]*TEXT_AFTER/);
423
+
424
+ // Toggle checkbox to show rows
425
+ await fireEvent.click(await canvas.findByTestId('toggle-rows'));
426
+
427
+ // Now 3 rows should be visible
428
+ expect(await canvas.findByTestId('row-1')).toBeInTheDocument();
429
+ expect(await canvas.findByTestId('row-2')).toBeInTheDocument();
430
+ expect(await canvas.findByTestId('row-3')).toBeInTheDocument();
431
+ expect(tbody.querySelectorAll('tr').length).toBe(3);
432
+ expect(justTextContainer.textContent).toMatch(/JUST_TEXT_BEFORE[\\s\\S]*A1 #/);
433
+ expect(justTextContainer.textContent).toMatch(/C3 #[\\s\\S]*JUST_TEXT_AFTER/);
434
+
435
+ // Verify rows are inside the table (TR should be children of TBODY)
436
+ const rows = tbody.querySelectorAll('tr');
437
+ rows.forEach(row => {
438
+ expect(row.parentElement).toBe(tbody);
439
+ });
440
+
441
+ // Verify table content is between TEXT_BEFORE and TEXT_AFTER
442
+ expect(container.textContent).toMatch(/TEXT_BEFORE[\\s\\S]*?Col A[\\s\\S]*?Col B[\\s\\S]*?Col C[\\s\\S]*?A1[\\s\\S]*?A2[\\s\\S]*?A3[\\s\\S]*?B1[\\s\\S]*?B2[\\s\\S]*?B3[\\s\\S]*?C1[\\s\\S]*?C2[\\s\\S]*?C3[\\s\\S]*?TEXT_AFTER/);
443
+
444
+ // Verify no content leaked outside the table
445
+ const tableHtml = table.outerHTML;
446
+ expect(tableHtml).toContain('A1');
447
+ expect(tableHtml).toContain('C3');
448
+ }
449
+ }`,...n.parameters?.docs?.source}}};const v=["ForEach","ForEach_0_2_N","ForEach_Table_3x3"];export{l as ForEach,c as ForEach_0_2_N,n as ForEach_Table_3x3,v as __namedExportsOrder,y as default};
@@ -1,4 +1,4 @@
1
- import{w as l,e as a,u as c}from"./index-CGuyH0k-.js";import"./custom-element-CnmjNo0g.js";function d(i){const{title:e,tag:t,template:s,payload:n}=i;return`
1
+ import{w as l,e as a,u as c}from"./index-CGuyH0k-.js";import"./custom-element-wuk8gYiP.js";function d(i){const{title:e,tag:t,template:s,payload:n}=i;return`
2
2
  <fieldset>
3
3
  <legend>${e}</legend>
4
4
  <custom-element tag="${t}" hidden>
@@ -0,0 +1,213 @@
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>for-each - Declarative Custom Element implementation demo</title>
6
+ <link rel="icon" href="./wc-square.svg"/>
7
+
8
+ <script type="module" src="../custom-element.js"></script>
9
+ <style>
10
+ @import "./demo.css";
11
+
12
+ table {
13
+ border-collapse: collapse;
14
+ margin: 1rem 0;
15
+ }
16
+ th, td {
17
+ border: 1px solid #ccc;
18
+ padding: 0.5rem;
19
+ }
20
+ th {
21
+ background: #f0f0f0;
22
+ }
23
+ </style>
24
+ </head>
25
+ <body>
26
+
27
+ <nav>
28
+ <a href="../index.html"><h3><code>custom-element</code> demo</h3></a>
29
+ <h3>for-each loop</h3>
30
+ <p>The <code>&lt;for-each&gt;</code> element iterates over a node-set selected by XPath expression
31
+ and renders its content for each node.</p>
32
+ <p><b>XHTML namespace use</b><br/>
33
+ HTML elements like <code>&lt;table&gt;</code>, <code>&lt;tr&gt;</code>, <code>&lt;td&gt;</code>
34
+ have strict content model rules - only specific child elements are permitted.
35
+ For example, <code>&lt;table&gt;</code> only allows <code>&lt;thead&gt;</code>,
36
+ <code>&lt;tbody&gt;</code>, <code>&lt;tr&gt;</code> as children; <code>&lt;tr&gt;</code>
37
+ only allows <code>&lt;th&gt;</code> or <code>&lt;td&gt;</code>.<br/>
38
+ When the browser parses HTML, it moves non-permitted elements (like <code>&lt;for-each&gt;</code>)
39
+ outside the table before JavaScript runs.<br/>
40
+ Using <code>xhtml:</code> namespace prefix (e.g., <code>&lt;xhtml:table&gt;</code>,
41
+ <code>&lt;xhtml:tr&gt;</code>) prevents the browser from recognizing these as standard HTML
42
+ elements during initial parsing, preserving the template structure for DCE to process correctly.
43
+ See examples 4 and 6.
44
+ </p>
45
+ </nav>
46
+
47
+ <html-demo-element legend="1. Simple for-each"
48
+ description="Loop over inline XML data and render each item">
49
+ <template>
50
+ <custom-element>
51
+ <template>
52
+ <xsl:variable name="fruits">
53
+ <item>Apple</item>
54
+ <item>Banana</item>
55
+ <item>Cherry</item>
56
+ </xsl:variable>
57
+ <ul>
58
+ <for-each select="exsl:node-set($fruits)/*">
59
+ <li>{.}</li>
60
+ </for-each>
61
+ </ul>
62
+ </template>
63
+ </custom-element>
64
+ </template>
65
+ </html-demo-element>
66
+
67
+ <html-demo-element legend="2. for-each with position()"
68
+ description="Using position() to number items in the loop">
69
+ <template>
70
+ <custom-element>
71
+ <template>
72
+ <xsl:variable name="colors">
73
+ <color hex="#ff0000">Red</color>
74
+ <color hex="#00ff00">Green</color>
75
+ <color hex="#0000ff">Blue</color>
76
+ </xsl:variable>
77
+ <for-each select="exsl:node-set($colors)/*">
78
+ <div style="padding: 0.5rem; background: {@hex}; color: white;">
79
+ {position()}. {.}
80
+ </div>
81
+ </for-each>
82
+ </template>
83
+ </custom-element>
84
+ </template>
85
+ </html-demo-element>
86
+
87
+ <html-demo-element legend="3. Conditional for-each"
88
+ description="Initially empty, items shown when checkbox is checked">
89
+ <template>
90
+ <custom-element>
91
+ <template>
92
+ <xsl:variable name="items">
93
+ <item>First</item>
94
+ <item>Second</item>
95
+ <item>Third</item>
96
+ </xsl:variable>
97
+ <label>
98
+ <input type="checkbox" slice="show-items" value="yes"/>
99
+ Show items
100
+ </label>
101
+ <variable name="show" select="//show-items = 'yes'"></variable>
102
+ <div>
103
+ BEFORE
104
+ <for-each select="exsl:node-set($items)/*[$show]">
105
+ <span style="margin: 0 0.25rem; padding: 0.25rem; background: #e0e0ff;">
106
+ {position()}:{.}
107
+ </span>
108
+ </for-each>
109
+ AFTER
110
+ </div>
111
+ </template>
112
+ </custom-element>
113
+ </template>
114
+ </html-demo-element>
115
+
116
+ <html-demo-element legend="4. Nested for-each (Table)"
117
+ description="Nested loops to render table rows and cells">
118
+ <template>
119
+ <custom-element>
120
+ <template>
121
+ <xsl:variable name="table-data">
122
+ <row><cell>A1</cell><cell>A2</cell><cell>A3</cell></row>
123
+ <row><cell>B1</cell><cell>B2</cell><cell>B3</cell></row>
124
+ <row><cell>C1</cell><cell>C2</cell><cell>C3</cell></row>
125
+ </xsl:variable>
126
+ <variable name="rows" select="exsl:node-set($table-data)/*"></variable>
127
+ <xhtml:table>
128
+ <xhtml:thead>
129
+ <xhtml:tr>
130
+ <xhtml:th>Col 1</xhtml:th>
131
+ <xhtml:th>Col 2</xhtml:th>
132
+ <xhtml:th>Col 3</xhtml:th>
133
+ </xhtml:tr>
134
+ </xhtml:thead>
135
+ <xhtml:tbody>
136
+ <for-each select="$rows">
137
+ <xhtml:tr>
138
+ <for-each select="*">
139
+ <xhtml:td>{.}</xhtml:td>
140
+ </for-each>
141
+ </xhtml:tr>
142
+ </for-each>
143
+ </xhtml:tbody>
144
+ </xhtml:table>
145
+ </template>
146
+ </custom-element>
147
+ </template>
148
+ </html-demo-element>
149
+
150
+ <html-demo-element legend="5. for-each with attributes"
151
+ description="Access element attributes within the loop">
152
+ <template>
153
+ <custom-element>
154
+ <template>
155
+ <xsl:variable name="users">
156
+ <user id="1" role="admin">Alice</user>
157
+ <user id="2" role="editor">Bob</user>
158
+ <user id="3" role="viewer">Charlie</user>
159
+ </xsl:variable>
160
+ <for-each select="exsl:node-set($users)/*">
161
+ <div style="padding: 0.5rem; margin: 0.25rem 0; border-left: 3px solid #007bff;">
162
+ <strong>#{@id}</strong> {.}
163
+ <em>({@role})</em>
164
+ </div>
165
+ </for-each>
166
+ </template>
167
+ </custom-element>
168
+ </template>
169
+ </html-demo-element>
170
+
171
+ <html-demo-element legend="6. Dynamic table with toggle"
172
+ description="Table rows appear/disappear based on checkbox state">
173
+ <template>
174
+ <custom-element>
175
+ <template>
176
+ <xsl:variable name="products">
177
+ <product price="10">Widget</product>
178
+ <product price="25">Gadget</product>
179
+ <product price="15">Gizmo</product>
180
+ </xsl:variable>
181
+ <variable name="items" select="exsl:node-set($products)/*"></variable>
182
+ <label>
183
+ <input type="checkbox" slice="show-products" value="yes"/>
184
+ Show products
185
+ </label>
186
+ <variable name="visible" select="//show-products = 'yes'"></variable>
187
+ <xhtml:table>
188
+ <xhtml:thead>
189
+ <xhtml:tr>
190
+ <xhtml:th>#</xhtml:th>
191
+ <xhtml:th>Product</xhtml:th>
192
+ <xhtml:th>Price</xhtml:th>
193
+ </xhtml:tr>
194
+ </xhtml:thead>
195
+ <xhtml:tbody>
196
+ <for-each select="$items[$visible]">
197
+ <xhtml:tr>
198
+ <xhtml:td>{position()}</xhtml:td>
199
+ <xhtml:td>{.}</xhtml:td>
200
+ <xhtml:td>${@price}</xhtml:td>
201
+ </xhtml:tr>
202
+ </for-each>
203
+ </xhtml:tbody>
204
+ </xhtml:table>
205
+ </template>
206
+ </custom-element>
207
+ </template>
208
+ </html-demo-element>
209
+
210
+ <script type="module" src="https://unpkg.com/html-demo-element@1/html-demo-element.js"></script>
211
+
212
+ </body>
213
+ </html>
@@ -517,7 +517,7 @@
517
517
  }
518
518
  }
519
519
  </script>
520
- <script type="module" crossorigin src="./assets/iframe-DiVWehoI.js"></script>
520
+ <script type="module" crossorigin src="./assets/iframe-CBHPj1E5.js"></script>
521
521
  </head>
522
522
 
523
523
  <body>