File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -7,11 +7,11 @@ const ids = umap(new WeakMap);
77let id = 0 ;
88
99const tag = type => ( template , ...values ) => ( {
10+ id : ids . get ( template ) ||
11+ ids . set ( template , id ++ ) ,
1012 type,
11- template,
1213 values,
13- id : ids . get ( template ) ||
14- ids . set ( template , id ++ )
14+ template
1515} ) ;
1616
1717html . json = tag ( 'html' ) ;
@@ -35,10 +35,10 @@ const asJSON = value => isJSON(value) ? unroll(value) : value;
3535const isJSON = thing => (
3636 typeof thing === 'object' &&
3737 thing !== null &&
38+ 'id' in thing &&
3839 'type' in thing &&
39- 'template' in thing &&
4040 'values' in thing &&
41- 'id ' in thing
41+ 'template ' in thing
4242) ;
4343
4444const render = ( where , what ) => $render (
Original file line number Diff line number Diff line change @@ -6,11 +6,11 @@ const ids = umap(new WeakMap);
66let id = 0 ;
77
88const tag = type => ( template , ...values ) => ( {
9+ id : ids . get ( template ) ||
10+ ids . set ( template , id ++ ) ,
911 type,
10- template,
1112 values,
12- id : ids . get ( template ) ||
13- ids . set ( template , id ++ )
13+ template
1414} ) ;
1515
1616html . json = tag ( 'html' ) ;
@@ -34,10 +34,10 @@ const asJSON = value => isJSON(value) ? unroll(value) : value;
3434const isJSON = thing => (
3535 typeof thing === 'object' &&
3636 thing !== null &&
37+ 'id' in thing &&
3738 'type' in thing &&
38- 'template' in thing &&
3939 'values' in thing &&
40- 'id ' in thing
40+ 'template ' in thing
4141) ;
4242
4343const render = ( where , what ) => $render (
Original file line number Diff line number Diff line change 88 < script type ="module ">
99 import { render , html } from '../esm/json.js' ;
1010 const strong = name => html . json `<strong>${ name } </strong>` ;
11- const greetings = name => html . json `
11+ const greetings = name => JSON . parse ( JSON . stringify ( html . json `
1212 <div>Hello ${ strong ( name ) } 👋</div>
13- ` ;
13+ ` ) ) ;
1414
1515 console . log ( greetings ( 'console' ) ) ;
1616 render ( document . body , greetings ( 'World' ) ) ;
You can’t perform that action at this time.
0 commit comments