@@ -1142,6 +1142,36 @@ var hyperHTML = (function (document) {
11421142 var CONNECTED = 'connected' ;
11431143 var DISCONNECTED = 'dis' + CONNECTED ;
11441144
1145+ var templateLiteral = function ( ) {
1146+
1147+ var RAW = 'raw' ;
1148+ var isNoOp = false ;
1149+ var _templateLiteral = function templateLiteral ( tl ) {
1150+ if (
1151+ // for badly transpiled literals
1152+ ! ( RAW in tl ) ||
1153+ // for some version of TypeScript
1154+ tl . propertyIsEnumerable ( RAW ) ||
1155+ // and some other version of TypeScript
1156+ ! Object . isFrozen ( tl . raw ) ||
1157+ // or for Firefox < 55
1158+ / F i r e f o x \/ ( \d + ) / . test ( ( document . defaultView . navigator || { } ) . userAgent ) && parseFloat ( RegExp . $1 ) < 55 ) {
1159+ var forever = { } ;
1160+ _templateLiteral = function templateLiteral ( tl ) {
1161+ var key = RAW + tl . join ( RAW ) ;
1162+ return forever [ key ] || ( forever [ key ] = tl ) ;
1163+ } ;
1164+ return _templateLiteral ( tl ) ;
1165+ } else {
1166+ isNoOp = true ;
1167+ return tl ;
1168+ }
1169+ } ;
1170+ return function ( tl ) {
1171+ return isNoOp ? tl : _templateLiteral ( tl ) ;
1172+ } ;
1173+ } ( ) ;
1174+
11451175 // these are tiny helpers to simplify most common operations needed here
11461176 var doc = function doc ( node ) {
11471177 return node . ownerDocument || node ;
@@ -1167,6 +1197,14 @@ var hyperHTML = (function (document) {
11671197 }
11681198 } ;
11691199
1200+ // normalizes the template once for all arguments cases
1201+ var reArguments = function reArguments ( template ) {
1202+ var args = [ templateLiteral ( template ) ] ;
1203+ for ( var i = 1 , length = arguments . length ; i < length ; i ++ ) {
1204+ args [ i ] = arguments [ i ] ;
1205+ } return args ;
1206+ } ;
1207+
11701208 // just recycling a one-off array to use slice
11711209 // in every needed place
11721210 var slice = [ ] . slice ;
@@ -1467,36 +1505,6 @@ var hyperHTML = (function (document) {
14671505 }
14681506 } ;
14691507
1470- var templateLiteral = function ( ) {
1471-
1472- var RAW = 'raw' ;
1473- var isNoOp = false ;
1474- var _templateLiteral = function templateLiteral ( tl ) {
1475- if (
1476- // for badly transpiled literals
1477- ! ( RAW in tl ) ||
1478- // for some version of TypeScript
1479- tl . propertyIsEnumerable ( RAW ) ||
1480- // and some other version of TypeScript
1481- ! Object . isFrozen ( tl . raw ) ||
1482- // or for Firefox < 55
1483- / F i r e f o x \/ ( \d + ) / . test ( ( document . defaultView . navigator || { } ) . userAgent ) && parseFloat ( RegExp . $1 ) < 55 ) {
1484- var forever = { } ;
1485- _templateLiteral = function templateLiteral ( tl ) {
1486- var key = RAW + tl . join ( RAW ) ;
1487- return forever [ key ] || ( forever [ key ] = tl ) ;
1488- } ;
1489- return _templateLiteral ( tl ) ;
1490- } else {
1491- isNoOp = true ;
1492- return tl ;
1493- }
1494- } ;
1495- return function ( tl ) {
1496- return isNoOp ? tl : _templateLiteral ( tl ) ;
1497- } ;
1498- } ( ) ;
1499-
15001508 // all wires used per each context
15011509 var wires = new WeakMap$1 ( ) ;
15021510
@@ -1523,14 +1531,14 @@ var hyperHTML = (function (document) {
15231531 var wire = void 0 ,
15241532 tagger = void 0 ,
15251533 template = void 0 ;
1526- return function ( statics ) {
1527- statics = templateLiteral ( statics ) ;
1528- if ( template !== statics ) {
1529- template = statics ;
1534+ return function ( ) {
1535+ var args = reArguments . apply ( null , arguments ) ;
1536+ if ( template !== args [ 0 ] ) {
1537+ template = args [ 0 ] ;
15301538 tagger = new Tagger ( type ) ;
1531- wire = wireContent ( tagger . apply ( tagger , arguments ) ) ;
1539+ wire = wireContent ( tagger . apply ( tagger , args ) ) ;
15321540 } else {
1533- tagger . apply ( tagger , arguments ) ;
1541+ tagger . apply ( tagger , args ) ;
15341542 }
15351543 return wire ;
15361544 } ;
@@ -1582,12 +1590,13 @@ var hyperHTML = (function (document) {
15821590 // the main tag function in charge of fully upgrading
15831591 // or simply updating, contexts used as hyperHTML targets.
15841592 // The `this` context is either a regular DOM node or a fragment.
1585- function render ( template ) {
1593+ function render ( ) {
15861594 var wicked = bewitched . get ( this ) ;
1587- if ( wicked && wicked . template === templateLiteral ( template ) ) {
1588- wicked . tagger . apply ( null , arguments ) ;
1595+ var args = reArguments . apply ( null , arguments ) ;
1596+ if ( wicked && wicked . template === args [ 0 ] ) {
1597+ wicked . tagger . apply ( null , args ) ;
15891598 } else {
1590- upgrade . apply ( this , arguments ) ;
1599+ upgrade . apply ( this , args ) ;
15911600 }
15921601 return this ;
15931602 }
@@ -1596,13 +1605,13 @@ var hyperHTML = (function (document) {
15961605 // parse it once, if unknown, to map all interpolations
15971606 // as single DOM callbacks, relate such template
15981607 // to the current context, and render it after cleaning the context up
1599- function upgrade ( template ) {
1600- template = templateLiteral ( template ) ;
1608+ function upgrade ( ) {
1609+ var args = reArguments . apply ( null , arguments ) ;
16011610 var type = OWNER_SVG_ELEMENT in this ? 'svg' : 'html' ;
16021611 var tagger = new Tagger ( type ) ;
1603- bewitched . set ( this , { tagger : tagger , template : template } ) ;
1612+ bewitched . set ( this , { tagger : tagger , template : args [ 0 ] } ) ;
16041613 this . textContent = '' ;
1605- this . appendChild ( tagger . apply ( null , arguments ) ) ;
1614+ this . appendChild ( tagger . apply ( null , args ) ) ;
16061615 }
16071616
16081617 /*! (c) Andrea Giammarchi (ISC) */
0 commit comments