@@ -94,9 +94,11 @@ var hyperHTML = (function (document) {
9494
9595 var WeakSet$1 = self$1 . WeakSet ;
9696
97- var iOF = [ ] . indexOf ;
97+ var _ref = [ ] ,
98+ indexOf = _ref . indexOf ;
99+
98100 var append = function append ( get , parent , children , start , end , before ) {
99- var isSelect = 'selectedIndex' in parent ;
101+ var isSelect = ( 'selectedIndex' in parent ) ;
100102 var noSelection = isSelect ;
101103
102104 while ( start < end ) {
@@ -106,7 +108,7 @@ var hyperHTML = (function (document) {
106108 if ( isSelect && noSelection && child . selected ) {
107109 noSelection = ! noSelection ;
108110 var selectedIndex = parent . selectedIndex ;
109- parent . selectedIndex = selectedIndex < 0 ? start : iOF . call ( parent . querySelectorAll ( 'option' ) , child ) ;
111+ parent . selectedIndex = selectedIndex < 0 ? start : indexOf . call ( parent . querySelectorAll ( 'option' ) , child ) ;
110112 }
111113
112114 start ++ ;
@@ -118,7 +120,7 @@ var hyperHTML = (function (document) {
118120 var identity = function identity ( O ) {
119121 return O ;
120122 } ;
121- var indexOf = function indexOf ( moreNodes , moreStart , moreEnd , lessNodes , lessStart , lessEnd , compare ) {
123+ var indexOf$1 = function indexOf ( moreNodes , moreStart , moreEnd , lessNodes , lessStart , lessEnd , compare ) {
122124 var length = lessEnd - lessStart ;
123125 /* istanbul ignore if */
124126
@@ -432,7 +434,7 @@ var hyperHTML = (function (document) {
432434 var i = - 1 ; // 2 simple indels: the shortest sequence is a subsequence of the longest
433435
434436 if ( currentChanges < futureChanges ) {
435- i = indexOf ( futureNodes , futureStart , futureEnd , currentNodes , currentStart , currentEnd , compare ) ; // inner diff
437+ i = indexOf$1 ( futureNodes , futureStart , futureEnd , currentNodes , currentStart , currentEnd , compare ) ; // inner diff
436438
437439 if ( - 1 < i ) {
438440 append ( get , parentNode , futureNodes , futureStart , i , get ( currentNodes [ currentStart ] , 0 ) ) ;
@@ -442,7 +444,7 @@ var hyperHTML = (function (document) {
442444 }
443445 /* istanbul ignore else */
444446 else if ( futureChanges < currentChanges ) {
445- i = indexOf ( currentNodes , currentStart , currentEnd , futureNodes , futureStart , futureEnd , compare ) ; // outer diff
447+ i = indexOf$1 ( currentNodes , currentStart , currentEnd , futureNodes , futureStart , futureEnd , compare ) ; // outer diff
446448
447449 if ( - 1 < i ) {
448450 remove ( get , currentNodes , currentStart , i ) ;
@@ -761,7 +763,7 @@ var hyperHTML = (function (document) {
761763
762764 var FRAGMENT = 'fragment' ;
763765 var TEMPLATE = 'template' ;
764- var HAS_CONTENT = 'content' in create ( TEMPLATE ) ;
766+ var HAS_CONTENT = ( 'content' in create ( TEMPLATE ) ) ;
765767 var createHTML = HAS_CONTENT ? function ( html ) {
766768 var template = create ( TEMPLATE ) ;
767769 template . innerHTML = html ;
@@ -907,7 +909,7 @@ var hyperHTML = (function (document) {
907909
908910 /*! (c) Andrea Giammarchi - ISC */
909911 var importNode = function ( document , appendChild , cloneNode , createTextNode , importNode ) {
910- var _native = importNode in document ; // IE 11 has problems with cloning templates:
912+ var _native = ( importNode in document ) ; // IE 11 has problems with cloning templates:
911913 // it "forgets" empty childNodes. This feature-detects that.
912914
913915
@@ -980,6 +982,22 @@ var hyperHTML = (function (document) {
980982 return VOID_ELEMENTS . test ( $1 ) ? $0 : '<' + $1 + $2 + '></' + $1 + '>' ;
981983 }
982984
985+ var umap = ( function ( _ ) {
986+ return {
987+ // About: get: _.get.bind(_)
988+ // It looks like WebKit/Safari didn't optimize bind at all,
989+ // so that using bind slows it down by 60%.
990+ // Firefox and Chrome are just fine in both cases,
991+ // so let's use the approach that works fast everywhere 👍
992+ get : function get ( key ) {
993+ return _ . get ( key ) ;
994+ } ,
995+ set : function set ( key , value ) {
996+ return _ . set ( key , value ) , value ;
997+ }
998+ } ;
999+ } ) ;
1000+
9831001 /* istanbul ignore next */
9841002
9851003 var normalizeAttributes = UID_IE ? function ( attributes , parts ) {
@@ -1173,7 +1191,7 @@ var hyperHTML = (function (document) {
11731191 }
11741192
11751193 // globals
1176- var parsed = new WeakMap$1 ( ) ;
1194+ var parsed = umap ( new WeakMap$1 ( ) ) ;
11771195
11781196 function createInfo ( options , template ) {
11791197 var markup = ( options . convert || sanitize ) ( template ) ;
@@ -1183,7 +1201,7 @@ var hyperHTML = (function (document) {
11831201 cleanContent ( content ) ;
11841202 var holes = [ ] ;
11851203 parse ( content , holes , template . slice ( 0 ) , [ ] ) ;
1186- var info = {
1204+ return {
11871205 content : content ,
11881206 updates : function updates ( content ) {
11891207 var updates = [ ] ;
@@ -1262,12 +1280,10 @@ var hyperHTML = (function (document) {
12621280 } ;
12631281 }
12641282 } ;
1265- parsed . set ( template , info ) ;
1266- return info ;
12671283 }
12681284
12691285 function createDetails ( options , template ) {
1270- var info = parsed . get ( template ) || createInfo ( options , template ) ;
1286+ var info = parsed . get ( template ) || parsed . set ( template , createInfo ( options , template ) ) ;
12711287 return info . updates ( importNode . call ( document , info . content , true ) ) ;
12721288 }
12731289
@@ -1530,7 +1546,7 @@ var hyperHTML = (function (document) {
15301546 // so that you can style=${{width: 120}}. In this case, the behavior has been
15311547 // fully inspired by Preact library and its simplicity.
15321548 attribute : function attribute ( node , name , original ) {
1533- var isSVG = OWNER_SVG_ELEMENT in node ;
1549+ var isSVG = ( OWNER_SVG_ELEMENT in node ) ;
15341550 var oldValue ; // if the attribute is the style one
15351551 // handle it differently from others
15361552
0 commit comments