@epa-wg/custom-element 0.0.24 → 0.0.26

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 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.24/coverage/src/custom-element/coverage.svg
352
- [coverage-url]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.24/coverage/src/custom-element/index.html
353
- [storybook-url]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.24/storybook-static/index.html?path=/story/welcome--introduction
351
+ [coverage-image]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.26/coverage/src/custom-element/coverage.svg
352
+ [coverage-url]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.26/coverage/src/custom-element/index.html
353
+ [storybook-url]: https://unpkg.com/@epa-wg/custom-element-dist@0.0.26/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
@@ -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.24",
119
+ "version": "0.0.26",
120
120
  "js-types-syntax": "typescript",
121
121
  "description-markup": "markdown",
122
122
  "contributions": {
package/custom-element.js CHANGED
@@ -9,12 +9,22 @@ const attr = (el, attr)=> el.getAttribute?.(attr)
9
9
  , isText = e => e.nodeType === 3
10
10
  , isString = s => typeof s === 'string'
11
11
  , isNode = e => e && typeof e.nodeType === 'number'
12
- , create = ( tag, t = '', d=document ) => ( e => ((t && e.append(createText(d.ownerDocument||d, t))),e) )((d.ownerDocument || d ).createElement( tag ))
13
12
  , createText = ( d, t) => (d.ownerDocument || d ).createTextNode( t )
14
13
  , removeChildren = n => { while(n.firstChild) n.firstChild.remove(); return n; }
15
14
  , emptyNode = n => { n.getAttributeNames().map( a => n.removeAttribute(a) ); return removeChildren(n); }
16
15
  , xslNs = x => ( x?.setAttribute('xmlns:xsl', XSL_NS_URL ), x )
17
16
  , xslHtmlNs = x => ( x?.setAttribute('xmlns:xhtml', HTML_NS_URL ), xslNs(x) )
17
+ , isValidTagName = tag=> ( /^[_a-zA-Z][-_:a-zA-Z0-9]*$/ .test(tag) )
18
+ , create = ( tag, t = '', d=document ) =>
19
+ {
20
+ const create = tag => ( e => ((t && e.append(createText(d.ownerDocument||d, t))),e) )((d.ownerDocument || d ).createElement( tag ))
21
+
22
+ if( isValidTagName(tag) )
23
+ return create(tag)
24
+ const e = create('dce-object');
25
+ e.setAttribute('dce-object-name',tag)
26
+ return e;
27
+ }
18
28
  , cloneAs = (p,tag) =>
19
29
  { const px = p.ownerDocument.createElementNS(p.namespaceURI,tag);
20
30
  for( let a of p.attributes)
@@ -86,7 +96,7 @@ obj2node( o, tag, doc )
86
96
  if( isNode(o[k]) || typeof o[k] ==='function' || o[k] instanceof Window )
87
97
  continue
88
98
  else
89
- if( typeof o[k] !== "object" )
99
+ if( typeof o[k] !== "object" && isValidTagName(k) )
90
100
  ret.setAttribute(k, o[k] );
91
101
  else
92
102
  ret.append(obj2node(o[k], k, doc))
@@ -249,7 +259,7 @@ createXsltFromDom( templateNode, S = 'xsl:stylesheet' )
249
259
  for( const c of fr.childNodes )
250
260
  payload.append(xslDom.importNode(c,true))
251
261
 
252
- const embeddedTemplates = [...payload.querySelectorAll('template')];
262
+ const embeddedTemplates = [...payload.getElementsByTagName('xsl:template')];
253
263
  embeddedTemplates.forEach(t=>payload.ownerDocument.documentElement.append(t));
254
264
 
255
265
  const slotCall = $(xslDom,'call-template[name="slot"]')
@@ -278,8 +288,9 @@ xhrTemplate(src)
278
288
  // xhr.overrideMimeType("text/xml");
279
289
  xhr.onload = () =>
280
290
  { if( xhr.readyState === xhr.DONE && xhr.status === 200 )
281
- resolve( xhr.responseXML || create('div', xhr.responseText ) )
282
- reject(xhr.statusText)
291
+ resolve( xhr.responseXML?.body || xhr.responseXML || create('div', xhr.responseText ) )
292
+ else
293
+ reject(`${xhr.statusText} - ${src}`)
283
294
  };
284
295
  xhr.addEventListener("error", ev=>reject(ev) );
285
296
 
@@ -362,7 +373,7 @@ event2slice( x, sliceNames, ev, dce )
362
373
  s.append( obj2node(new FormData(el),'value', s.ownerDocument) )
363
374
  return s
364
375
  }
365
- const v = el.value ?? attr( sel, 'value' ) ;
376
+ const v = el.value ?? attr( el, 'value' ) ;
366
377
  cleanSliceValue();
367
378
  if( v === null || v === undefined )
368
379
  [...s.childNodes].filter(n=>n.localName!=='event').map(n=>n.remove());
@@ -386,19 +397,27 @@ const loadTemplateRoots = async ( src, dce )=>
386
397
  return [dce]
387
398
  if( src.startsWith('#') )
388
399
  return ( n =>
389
- { if(!n) return []
390
- const a = n.querySelectorAll(src)
391
- if( a.length )
392
- return [...a]
393
- const r = n.getRootNode();
394
- return r===n ? []: getByHashId(r)
400
+ { const a = n.querySelectorAll(src)
401
+ return [...( a.length ? a : n.getRootNode().querySelectorAll(src) )]
395
402
  })(dce.parentElement)
396
403
  try
397
- { // todo cache
398
- const dom = await xhrTemplate(src)
399
- const hash = new URL(src, location).hash
404
+ { const [path, hash] = src.split('#');
405
+ if( '.' === src.charAt(0))
406
+ src = new URL(path, dce.closest('[base]')?.getAttribute('base') || location ).href;
407
+ else
408
+ try
409
+ { src = import.meta.resolve( path );
410
+ if(hash)
411
+ src +='#'+hash;
412
+ }
413
+ catch( e )
414
+ { console.error(e.message) }
415
+ // todo cache
416
+ const dom = await xhrTemplate(src);
417
+ dce.setAttributeNS('xml', 'base', src );
418
+
400
419
  if( hash )
401
- { const ret = dom.querySelectorAll(hash);
420
+ { const ret = dom.querySelectorAll('#'+hash);
402
421
  if( ret.length )
403
422
  return [...ret]
404
423
  return [dce]
@@ -444,8 +463,11 @@ export function appendByDceId(parent,e,k)
444
463
  }
445
464
  export function merge( parent, fromArr )
446
465
  {
447
- if(!fromArr.length)
448
- return removeChildren(parent);
466
+ if( 'dce-root' === parent.firstElementChild?.localName && 'dce-root' !== fromArr[0].localName)
467
+ return;
468
+ if( !fromArr.length )
469
+ return 'dce-root' !== parent.firstElementChild?.localName && removeChildren(parent);
470
+
449
471
  const id2old = {};
450
472
  for( let c of parent.childNodes)
451
473
  { ASSERT( !id2old[c.dceId] );
@@ -472,7 +494,8 @@ export function merge( parent, fromArr )
472
494
  appendByDceId(parent,e,k)
473
495
  }
474
496
  for( let v of Object.values(id2old) )
475
- v.remove();
497
+ if( v.localName !== 'dce-root')
498
+ v.remove();
476
499
  }
477
500
  export function assureUID(n,attr)
478
501
  { if( !n.hasAttribute(attr) )
@@ -513,7 +536,7 @@ export const xPath = (x,root)=>
513
536
  ret += n.textContent;
514
537
  return ret
515
538
  }
516
- export const xslTags = 'stylesheet,transform,import,include,strip-space,preserve-space,output,key,decimal-format,namespace-alias,template,value-of,copy-of,number,apply-templates,apply-imports,for-each,sort,if,choose,when,otherwise,attribute-set,call-template,with-param,variable,param,text,processing-instruction,element,attribute,comment,copy,message,fallback'.split(',');
539
+ export const xslTags = 'stylesheet,transform,import,include,strip-space,preserve-space,output,key,decimal-format,namespace-alias,value-of,copy-of,number,apply-templates,apply-imports,for-each,sort,if,choose,when,otherwise,attribute-set,call-template,with-param,variable,param,text,processing-instruction,element,attribute,comment,copy,message,fallback'.split(',');
517
540
  export const toXsl = (el, defParent) => {
518
541
  const x = create('xsl:'+el.localName);
519
542
  for( let a of el.attributes )
@@ -594,7 +617,9 @@ CustomElement extends HTMLElement
594
617
  e.append( createText( x, t ))
595
618
  return e;
596
619
  })(x.ownerDocument.createElement( tag ))
597
- injectData( x, 'payload' , payload , assureSlot );
620
+ const payloadNode = injectData( x, 'payload' , payload , assureSlot );
621
+ xslNs(payloadNode);
622
+ xslHtmlNs(payloadNode);
598
623
  this.innerHTML='';
599
624
  const attrsRoot = injectData( x, 'attributes' , this.attributes, e => createXmlNode( e.nodeName, e.value ) );
600
625
  injectData( x, 'dataset', Object.keys( this.dataset ), k => createXmlNode( k, this.dataset[ k ] ) );
@@ -654,7 +679,7 @@ CustomElement extends HTMLElement
654
679
  { if( !el.dceInitialized )
655
680
  { el.dceInitialized = 1;
656
681
  let evs = attr(el,'slice-event');
657
- if( attr(el,'custom-validity') )
682
+ if( el.hasAttribute('custom-validity') )
658
683
  evs += ' change submit';
659
684
 
660
685
  [...new Set((evs || 'change') .split(' '))]
@@ -713,13 +738,17 @@ CustomElement extends HTMLElement
713
738
  applySlices();
714
739
  }
715
740
  #applyAttribute(name, newValue)
716
- { let a = this.xml.querySelector(`attributes>${name}`);
741
+ { if( 'value' === name )
742
+ this.value = newValue;
743
+ let a = this.xml.querySelector(`attributes>${name}`);
717
744
  if( a )
718
745
  emptyNode(a).append( createText(a,newValue) );
719
746
  else
720
747
  { a = create( name, newValue, this.xml );
721
748
  this.xml.querySelector('attributes').append( a );
722
749
  }
750
+
751
+ this.dispatchEvent(new CustomEvent('change', { bubbles: true,detail: { [name]: newValue }}))
723
752
  }
724
753
  attributeChangedCallback(name, oldValue, newValue)
725
754
  { if( !this.xml || this.#inTransform )
package/demo/confused.svg CHANGED
@@ -1,5 +1,6 @@
1
1
  <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
2
  <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="48" height="48" version="1.0">
3
+ <title>Confused</title>
3
4
  <defs>
4
5
  <linearGradient id="d">
5
6
  <stop offset="0"/>
package/demo/demo.css CHANGED
@@ -11,9 +11,13 @@ custom-element:not([tag]),
11
11
  dce-link,dce-1-slot,dce-2-slot,dce-3-slot,dce-4-slot,dce-2-slots,greet-element,pokemon-tile,
12
12
  dce-1,dce-2,dce-3,dce-4,dce-internal,dce-hash
13
13
  { box-shadow: 0 0 0.5rem lime; padding: 1rem; display: inline-block; flex:1; }
14
+ script{ display:none !important; }
14
15
  dd{ padding: 1rem;}
15
16
  p{ margin: 0;}
16
-
17
+ code{ font-weight: bold; color: green; text-wrap: nowrap; }
18
+ *{
19
+ gap: 1rem;
20
+ }
17
21
 
18
22
  html-demo-element h3
19
23
  { text-shadow: 0 0 0.25em white;
package/demo/embed-1.html CHANGED
@@ -1,3 +1,2 @@
1
1
  <h4>embed-1.html</h4>
2
- <custom-element tag="dce-embed-1" hidden>🖖</custom-element>
3
- <dce-embed-1>?</dce-embed-1>
2
+ <custom-element><template>🖖</template></custom-element>
@@ -3,26 +3,61 @@
3
3
  <head>
4
4
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5
5
  <title>http-request Declarative Custom Element implementation demo</title>
6
- <link rel="icon" href="./wc-square.svg" />
6
+ <link rel="icon" href="./wc-square.svg"/>
7
7
 
8
8
  <script type="module" src="../http-request.js"></script>
9
9
  <script type="module" src="../custom-element.js"></script>
10
10
  <style>
11
11
  @import "./demo.css";
12
12
 
13
- button
14
- { display: inline-flex; flex-direction: column; align-items: center; flex: auto;
15
- box-shadow: inset silver 0 0 1rem; min-width: 12rem; padding: 1rem;
16
- color: coral; text-shadow: 1px 1px silver; font-weight: bolder;
13
+ button {
14
+ display: inline-flex;
15
+ flex-direction: column;
16
+ align-items: center;
17
+ flex: auto;
18
+ box-shadow: inset silver 0 0 1rem;
19
+ min-width: 12rem;
20
+ padding: 1rem;
21
+ color: coral;
22
+ text-shadow: 1px 1px silver;
23
+ font-weight: bolder;
24
+ }
25
+
26
+ button img {
27
+ max-height: 10vw;
28
+ min-height: 4rem;
29
+ }
30
+
31
+ table {
32
+ min-width: 16rem;
33
+ }
34
+
35
+ td {
36
+ border-bottom: 1px solid silver;
37
+ }
38
+
39
+ tfoot td {
40
+ border-bottom: none;
41
+ }
42
+
43
+ td, th {
44
+ text-align: right;
45
+ }
46
+
47
+ caption {
48
+ padding: 1rem;
49
+ font-weight: bolder;
50
+ font-family: sans-serif;
51
+ }
52
+
53
+ code {
54
+ text-align: right;
55
+ min-width: 3rem;
56
+ }
57
+
58
+ svg {
59
+ max-height: 3rem;
17
60
  }
18
- button img{ max-height: 10vw; min-height: 4rem;}
19
- table{ min-width: 16rem; }
20
- td{ border-bottom: 1px solid silver; }
21
- tfoot td{ border-bottom: none; }
22
- td,th{text-align: right; }
23
- caption{ padding: 1rem; font-weight: bolder; font-family: sans-serif; }
24
- code{ text-align: right; min-width: 3rem;}
25
- svg{ max-height: 3rem;}
26
61
  </style>
27
62
  </head>
28
63
  <body>
@@ -35,15 +70,16 @@
35
70
  <html-demo-element legend="1. reference the template in page DOM"
36
71
  description="should render hand wave with '👋 World!' and 'Hello World!'">
37
72
  <template>
38
- <template id="template1">
39
- <slot> Hello </slot> World!
40
- </template>
73
+ <template id="template1">
74
+ <slot> Hello</slot>
75
+ World!
76
+ </template>
41
77
 
42
- <custom-element tag="dce-internal" src="#template1"></custom-element>
43
- <!-- no need for loading fallback as the template exists -->
78
+ <custom-element tag="dce-internal" src="#template1"></custom-element>
79
+ <!-- no need for loading fallback as the template exists -->
44
80
 
45
- <dce-internal>👋</dce-internal>
46
- <dce-internal></dce-internal>
81
+ <dce-internal>👋</dce-internal>
82
+ <dce-internal></dce-internal>
47
83
  </template>
48
84
  </html-demo-element>
49
85
 
@@ -51,67 +87,67 @@
51
87
  <html-demo-element legend="2. without TAG, inline instantiation"
52
88
  description="hash value in SRC references template by ID. Should output 'construction' 2 times">
53
89
  <template>
54
- <template id="template2">
55
- 🏗️ construction
56
- </template>
90
+ <template id="template2">
91
+ 🏗️ construction
92
+ </template>
57
93
 
58
- <custom-element src="#template2"></custom-element>
59
- <custom-element src="#template2"></custom-element>
94
+ <custom-element src="#template2"></custom-element>
95
+ <custom-element src="#template2"></custom-element>
60
96
  </template>
61
97
  </html-demo-element>
62
98
 
63
- <html-demo-element legend="3. external SVG file" >
99
+ <html-demo-element legend="3. external SVG file">
64
100
  <template>
65
- <custom-element tag="dce-external" src="confused.svg" >
66
- <template><i>loading from SVG ...</i></template>
67
- </custom-element>
68
- <dce-external></dce-external>
69
- <custom-element src="confused.svg" >
70
- <i>inline DCE loading from SVG ...</i>
71
- </custom-element>
72
- <custom-element src="no.svg" >
73
- <i>fallback for missing image</i>
74
- </custom-element>
101
+ <custom-element tag="dce-external" src="confused.svg">
102
+ <template><i>loading from SVG ...</i></template>
103
+ </custom-element>
104
+ <dce-external></dce-external>
105
+ <custom-element src="confused.svg">
106
+ <i>inline DCE loading from SVG ...</i>
107
+ </custom-element>
108
+ <custom-element src="no.svg">
109
+ <i>fallback for missing image</i>
110
+ </custom-element>
75
111
  </template>
76
112
  </html-demo-element>
77
113
 
78
114
  <html-demo-element legend="4. external XSLT file"
79
115
  description="This external templates generated the tree for DCE data set"
80
- >
116
+ >
81
117
  <a href="tree.xsl">tree.xsl</a>
82
118
  <template>
83
- <custom-element tag="dce-external-4" src="tree.xsl" >
84
- <template><i>loading from XSLT ...</i></template>
85
- </custom-element>
86
- <dce-external-4 title="DCE with external XSLT template" data-fruit="🍌">Hi</dce-external-4>
87
- <custom-element src="tree.xsl" data-smile="👼" data-basket="🍒">
88
- <i>inline DCE loading from XSLT ...</i>
89
- </custom-element>
119
+ <custom-element tag="dce-external-4" src="tree.xsl">
120
+ <template><i>loading from XSLT ...</i></template>
121
+ </custom-element>
122
+ <dce-external-4 title="DCE with external XSLT template" data-fruit="🍌">Hi</dce-external-4>
123
+ <custom-element src="tree.xsl" data-smile="👼" data-basket="🍒">
124
+ <i>inline DCE loading from XSLT ...</i>
125
+ </custom-element>
90
126
  </template>
91
127
  </html-demo-element>
92
128
 
93
129
  <html-demo-element legend="5. external HTML template" description="Should render 👋👌, svg, formula">
94
130
  <template>
95
- <custom-element tag="dce-external-5" src="html-template.html" >
96
- <template><i>loading from HTML file ...</i></template>
97
- </custom-element>
98
- <dce-external-5 title="DCE with external XSLT template" data-fruit="🍌">Hi</dce-external-5>
99
- <custom-element src="html-template.html" data-smile="👼" data-basket="🍒">
100
- <i>inline DCE loading from HTML file ...</i>
101
- </custom-element>
131
+ <custom-element tag="dce-external-5" src="html-template.html">
132
+ <template><i>loading from HTML file ...</i></template>
133
+ </custom-element>
134
+ <dce-external-5 title="DCE with external XSLT template" data-fruit="🍌">Hi</dce-external-5>
135
+ <custom-element src="html-template.html" data-smile="👼" data-basket="🍒">
136
+ <i>inline DCE loading from HTML file ...</i>
137
+ </custom-element>
102
138
  </template>
103
139
  </html-demo-element>
104
140
 
105
141
  <html-demo-element legend="6. HTML, SVG by ID within external file" description="Should render 👋, svg, formula">
106
142
  <a href="html-template.html">html-template.html</a>
107
143
  <template>
108
- <custom-element src="html-template.html#wave" >
144
+ <custom-element src="html-template.html#wave">
109
145
  <template><i>loading HTML from templates file ...</i></template>
110
146
  </custom-element>
111
- <custom-element src="html-template.html#dwc-logo" >
112
- <template><i>loading SVG from templates file ...</i></template>
147
+ <custom-element src="html-template.html#dwc-logo">
148
+ <template><i>loading SVG from templates file ...</i></template>
113
149
  </custom-element>
114
- <custom-element src="html-template.html#sophomores-dream" >
150
+ <custom-element src="html-template.html#sophomores-dream">
115
151
  <template><i>loading MathML from HTML file ...</i></template>
116
152
  </custom-element>
117
153
  </template>
@@ -119,10 +155,10 @@
119
155
  <html-demo-element legend="7. XSLT by ID within external file" description="Should render tree, and fallback">
120
156
  <a href="html-template.html">html-template.html</a>
121
157
  <template>
122
- <custom-element src="html-template.xhtml#embedded-xsl" >
123
- <template>whole XSLT is embedded into HTML body</template>
158
+ <custom-element src="html-template.xhtml#embedded-xsl">
159
+ <template>whole XSLT is embedded into HTML body</template>
124
160
  </custom-element>
125
- <custom-element src="html-template.html#none" >
161
+ <custom-element src="html-template.html#none">
126
162
  <template><i>element with id=none is missing in template</i></template>
127
163
  </custom-element>
128
164
  </template>
@@ -132,13 +168,37 @@
132
168
  description="Should render Vulcan Salute 🖖"
133
169
  >
134
170
  <template>
135
- <custom-element src="embed-1.html" >
136
- loading from embed-1.html ...
137
- </custom-element>
171
+ <custom-element src="embed-1.html">
172
+ loading from embed-1.html ...
173
+ </custom-element>
174
+ </template>
175
+ </html-demo-element>
176
+
177
+
178
+ <html-demo-element legend="9. external file with invoking of relative template as hash by enclosed custom-element"
179
+ description="Should render Vulcan Salute 🖖"
180
+ >
181
+ <template>
182
+ <custom-element src="./lib-dir/embed-lib.html#embed-relative-hash">
183
+ loading from embed-1.html ...
184
+ </custom-element>
138
185
  </template>
139
186
  </html-demo-element>
140
- <html-demo-element legend="embed-1.html external file " src="embed-1.html">
187
+
188
+ <html-demo-element
189
+ legend="10. external file with invoking of template in another relative path file by enclosed custom-element"
190
+ description="Should render Vulcan Salute 🖖"
191
+ >
192
+ <template>
193
+ <custom-element src="./lib-dir/embed-lib.html#embed-relative-file">
194
+ loading from ./lib-dir/embed-lib.html ...
195
+ </custom-element>
196
+ </template>
141
197
  </html-demo-element>
198
+
199
+
200
+ <html-demo-element legend="embed-1.html external file" src="embed-1.html"></html-demo-element>
201
+ <html-demo-element legend="embed-lib.html with multiple templates" src="embed-lib.html"></html-demo-element>
142
202
  <!--
143
203
  <html-demo-element legend="9. deep external files, complex rendering" >
144
204
  <template>
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" standalone="no"?>
2
+ <!DOCTYPE svg>
3
+ <svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="32" height="32" baseProfile="full" viewBox="-21 -21 42 42">
4
+ <defs>
5
+ <radialGradient id="b" cx=".2" cy=".2" r=".5" fx=".2" fy=".2">
6
+ <stop offset="0" stop-color="#fff" stop-opacity=".7"/>
7
+ <stop offset="1" stop-color="#fff" stop-opacity="0"/>
8
+ </radialGradient>
9
+ <radialGradient id="a" cx=".5" cy=".5" r=".5">
10
+ <stop offset="0" stop-color="#ff0"/>
11
+ <stop offset=".75" stop-color="#ff0"/>
12
+ <stop offset=".95" stop-color="#ee0"/>
13
+ <stop offset="1" stop-color="#e8e800"/>
14
+ </radialGradient>
15
+ </defs>
16
+ <circle r="20" fill="url(#a)" stroke="#000" stroke-width=".15"/>
17
+ <circle r="20" fill="url(#b)"/>
18
+ <g id="c">
19
+ <ellipse cx="-6" cy="-7" rx="2.5" ry="4"/>
20
+ <path fill="none" stroke="#000" stroke-linecap="round" stroke-width=".5" d="M10.6 2.7a4 4 0 0 0 4 3"/>
21
+ </g>
22
+ <use xlink:href="#c" transform="scale(-1 1)"/>
23
+ <path fill="none" stroke="#000" stroke-width=".75" d="M-12 5a13.5 13.5 0 0 0 24 0 13 13 0 0 1-24 0"/>
24
+ </svg>
@@ -0,0 +1,34 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
5
+ <title>templates for embedded and external DCE lib dependencies</title>
6
+ </head>
7
+ <body>
8
+ <h1>templates for embedded and external DCE lib dependencies</h1>
9
+
10
+ <template id="embed-lib-component">
11
+ 👋 from embed-lib-component
12
+ </template>
13
+
14
+ <template id="embed-relative-hash">
15
+ 👌 from embed-relative-hash invoking
16
+ <module-url slice="full-url" src="./embed-lib.html"></module-url>
17
+ <a href="{//full-url}#embed-lib-component">
18
+ <img src="{//full-url}/../Smiley.svg"/>
19
+ #embed-lib-component
20
+ </a>:
21
+ <custom-element src="#embed-lib-component"></custom-element>
22
+ </template>
23
+
24
+ <template id="embed-relative-file">
25
+ 👍 from embed-relative-file invoking
26
+ <module-url slice="up-url" src="../embed-1.html"></module-url>
27
+ <a href="{//up-url}">../embed-1.html</a>:
28
+ <custom-element src="../embed-1.html">
29
+ loading from ../embed-1.html ...
30
+ </custom-element>
31
+ </template>
32
+
33
+ </body>
34
+ </html>
@@ -22,7 +22,19 @@
22
22
  <nav>
23
23
  <a href="../index.html"><h3><code>custom-element</code> demo</h3></a>
24
24
  </nav>
25
- <html-demo-element legend="Change window URL">
25
+ <main>
26
+ <h3>How to get the page URL by location-element?</h3>
27
+ Answer: by defining following attributes:
28
+ <ol>
29
+ <li><code>slice</code> to one of values provided bellow</li>
30
+ <li><code>src</code> optionally with URL, If omitted, it would match the <code>window.location.href</code> </li>
31
+ </ol>
32
+ URL properties would be a part of slice data.
33
+ <p><a href="./set-url.html">Set page URL demo</a> </p>
34
+ </main>
35
+ <html-demo-element legend="Change window URL"
36
+ description="use browser URL bar or those controls to change the page URL"
37
+ >
26
38
  <template>
27
39
  <a href="#dce2">#dce2</a>
28
40
  <form method="get">
@@ -40,7 +52,8 @@
40
52
 
41
53
 
42
54
  <html-demo-element legend="1. window.location live update"
43
- description="In the page beginning change the window URL via link or by history change"
55
+ description="Change the window URL via link or history change by controls in #1.
56
+ Observe the changes detected by location-element slice."
44
57
  id="dce2"
45
58
  >
46
59
  <p>Has to produce URL properties</p>
@@ -48,7 +61,7 @@
48
61
  <custom-element tag="dce-2" hidden>
49
62
  <template>
50
63
 
51
- <location-element slice="window-url" live></location-element>
64
+ <location-element slice="window-url" live method="" src=""></location-element>
52
65
 
53
66
  <xhtml:table>
54
67
  <xhtml:tbody>
@@ -121,7 +134,7 @@
121
134
  <custom-element tag="dce-3" hidden>
122
135
  <template>
123
136
 
124
- <location-element slice="href-url" href="https://my.example?a=1&b=2#3"></location-element>
137
+ <location-element slice="href-url" href="https://my.example?a=1&b=2#3" ></location-element>
125
138
 
126
139
  <xhtml:table>
127
140
  <xhtml:tbody>