1313
1414const CACHE = { } ;
1515
16+ const stringify = JSON . stringify ;
17+
1618export default function html ( statics ) {
17- const key = statics . length + statics ;
19+ const key = stringify ( statics ) ;
1820 const tpl = CACHE [ key ] || ( CACHE [ key ] = build ( statics ) ) ;
1921
2022 // eslint-disable-next-line prefer-rest-params
@@ -55,12 +57,12 @@ const build = (statics) => {
5557 if ( ! inTag ) {
5658 if ( field || ( buffer = buffer . replace ( / ^ \s * \n \s * | \s * \n \s * $ / g, '' ) ) ) {
5759 if ( hasChildren ++ ) out += ',' ;
58- out += field || JSON . stringify ( buffer ) ;
60+ out += field || stringify ( buffer ) ;
5961 }
6062 }
6163 else if ( mode === MODE_TAGNAME ) {
6264 if ( hasChildren ++ ) out += ',' ;
63- out += 'h(' + ( field || JSON . stringify ( buffer ) ) ;
65+ out += 'h(' + ( field || stringify ( buffer ) ) ;
6466 mode = MODE_WHITESPACE ;
6567 }
6668 else if ( mode === MODE_ATTRIBUTE || ( mode === MODE_WHITESPACE && buffer === '...' ) ) {
@@ -77,8 +79,8 @@ const build = (statics) => {
7779 if ( ! props ) props += '{' ;
7880 else props += ',' + ( propsClose ? '' : '{' ) ;
7981 propsClose = '}' ;
80- props += JSON . stringify ( propName ) + ':' ;
81- props += field || ( ( propHasValue || buffer ) && JSON . stringify ( buffer ) ) || 'true' ;
82+ props += stringify ( propName ) + ':' ;
83+ props += field || ( ( propHasValue || buffer ) && stringify ( buffer ) ) || 'true' ;
8284 propName = '' ;
8385 }
8486 propHasValue = false ;
0 commit comments