Skip to content

Commit

Permalink
Merge pull request #74 from EPA-WG/develop
Browse files Browse the repository at this point in the history
0.0.31
  • Loading branch information
sashafirsov authored Nov 12, 2024
2 parents d579abb + 318a9fa commit 749df88
Show file tree
Hide file tree
Showing 7 changed files with 49 additions and 10 deletions.
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,16 +341,16 @@ within template
[css-demo-url]: https://unpkg.com/@epa-wg/[email protected]/demo/scoped-css.html
[slice-demo-url]: https://unpkg.com/@epa-wg/[email protected]/demo/data-slices.html
[hex-grid-url]: https://unpkg.com/@epa-wg/[email protected]/demo/hex-grid.html
[hex-grid-image]: https://unpkg.com/@epa-wg/[email protected].29/demo/hex-grid-transform.png
[hex-grid-image]: https://unpkg.com/@epa-wg/[email protected].31/demo/hex-grid-transform.png
[local-storage-demo]: https://unpkg.com/@epa-wg/[email protected]/demo/local-storage.html
[http-request-demo]: https://unpkg.com/@epa-wg/[email protected]/demo/http-request.html
[location-demo]: https://unpkg.com/@epa-wg/[email protected]/demo/location.html
[github-image]: https://cdnjs.cloudflare.com/ajax/libs/octicons/8.5.0/svg/mark-github.svg
[npm-image]: https://img.shields.io/npm/v/@epa-wg/custom-element.svg
[npm-url]: https://npmjs.org/package/@epa-wg/custom-element
[coverage-image]: https://unpkg.com/@epa-wg/[email protected].29/coverage/src/custom-element/coverage.svg
[coverage-url]: https://unpkg.com/@epa-wg/[email protected].29/coverage/src/custom-element/index.html
[storybook-url]: https://unpkg.com/@epa-wg/[email protected].29/storybook-static/index.html?path=/story/welcome--introduction
[coverage-image]: https://unpkg.com/@epa-wg/[email protected].31/coverage/src/custom-element/coverage.svg
[coverage-url]: https://unpkg.com/@epa-wg/[email protected].31/coverage/src/custom-element/index.html
[storybook-url]: https://unpkg.com/@epa-wg/[email protected].31/storybook-static/index.html?path=/story/welcome--introduction
[sandbox-url]: https://stackblitz.com/github/EPA-WG/custom-element?file=index.html
[webcomponents-url]: https://www.webcomponents.org/element/@epa-wg/custom-element
[webcomponents-img]: https://img.shields.io/badge/webcomponents.org-published-blue.svg
Expand Down
2 changes: 1 addition & 1 deletion bin/xslDtd2Ide.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ writeFileSync( '.././ide/customData-xsl.json', JSON.stringify( vsCode, undefined
const intelliJ = {
"$schema": "http://json.schemastore.org/web-types",
"name": "@epa-wg/custom-element",
"version": "0.0.29",
"version": "0.0.31",
"js-types-syntax": "typescript",
"description-markup": "markdown",
"contributions": {
Expand Down
6 changes: 4 additions & 2 deletions custom-element.js
Original file line number Diff line number Diff line change
Expand Up @@ -423,12 +423,13 @@ event2slice( x, sliceNames, ev, dce )
s.setAttribute('validation-message', el.validationMessage);
ev.type==='init' && cleanSliceValue();
s.append( obj2node( ev, 'event', d ) );
const notChecked = ( 'checkbox' === el.type || 'radio' === el.type ) && !el.checked ;
if( sel.hasAttribute('slice-value') )
{ if( el.value === undefined)
s.removeAttribute('value')
else
s.setAttribute('value', el.value );
const v = xPath( attr( sel, 'slice-value'),s );
const v = notChecked? '' : xPath( attr( sel, 'slice-value'),s );
cleanSliceValue();
s.append( createText( d, v ) );
}else
Expand All @@ -437,7 +438,8 @@ event2slice( x, sliceNames, ev, dce )
s.append( obj2node(new FormData(el),'value', s.ownerDocument) )
return s
}
const v = el.value ?? attr( el, 'value' ) ;

const v = notChecked? '' : el.value ?? attr( el, 'value' );
cleanSliceValue();
if( v === null || v === undefined )
[...s.childNodes].filter(n=>n.localName!=='event').map(n=>n.remove());
Expand Down
37 changes: 37 additions & 0 deletions demo/data-slices.html
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,43 @@ <h3>Data slices propagation by events.</h3>
</template>
</html-demo-element>

<html-demo-element legend="12. checkbox use"
description="The value is empty when unchecked. Otherwise taken either from slice-value or value attribute.">
<p>Check the box to see the value in slice</p>
<template>
<custom-element>
<template>
<input type="checkbox" slice="is-checked" value="V0" checked/>
slice: {/datadom/slice/is-checked} <br/>
<xsl:variable name="v1">V1</xsl:variable> <br/>
$v1={$v1}<br/>

<!-- slice-variable is XPath. $v1 is available only in template, embedding trick -->
<input type="checkbox" slice="s2" slice-value="'{$v1}'"/>
slice 2: {//s2} <br/>

<!-- variable is used in template scope -->
<input type="checkbox" slice="s3" value="{$v1}"/>
slice 3: {//s3}
</template>
</custom-element>
</template>
</html-demo-element>

<html-demo-element legend="13. Radio group"
description="The value is empty when unchecked. Otherwise taken either from slice-value or value attribute.">
<p>Check the radiobutton to see the value in slice</p>
<template>
<custom-element>
<template>
V0: <input type="radio" slice="radio-group" value="V0" name="g1"/> <br/>
V1: <input type="radio" slice="radio-group" value="V1" name="g1" checked/> <br/>
slice: {//radio-group} <br/>
</template>
</custom-element>
</template>
</html-demo-element>

<script type="module" src="https://unpkg.com/html-demo-element@1/html-demo-element.js"></script>

</body>
Expand Down
2 changes: 1 addition & 1 deletion ide/web-types-dce.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json.schemastore.org/web-types",
"name": "@epa-wg/custom-element",
"version": "0.0.29",
"version": "0.0.31",
"js-types-syntax": "typescript",
"description-markup": "markdown",
"contributions": {
Expand Down
2 changes: 1 addition & 1 deletion ide/web-types-xsl.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"$schema": "http://json.schemastore.org/web-types",
"name": "@epa-wg/custom-element",
"version": "0.0.29",
"version": "0.0.31",
"js-types-syntax": "typescript",
"description-markup": "markdown",
"contributions": {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@epa-wg/custom-element",
"version": "0.0.29",
"version": "0.0.31",
"description": "Declarative Custom Element as W3C proposal PoC with native(XSLT) based templating",
"browser": "custom-element.js",
"module": "custom-element.js",
Expand Down

0 comments on commit 749df88

Please sign in to comment.