@@ -94,9 +94,11 @@ var hyperHTML = (function (document) {
94
94
95
95
var WeakSet$1 = self$1 . WeakSet ;
96
96
97
- var iOF = [ ] . indexOf ;
97
+ var _ref = [ ] ,
98
+ indexOf = _ref . indexOf ;
99
+
98
100
var append = function append ( get , parent , children , start , end , before ) {
99
- var isSelect = 'selectedIndex' in parent ;
101
+ var isSelect = ( 'selectedIndex' in parent ) ;
100
102
var noSelection = isSelect ;
101
103
102
104
while ( start < end ) {
@@ -106,7 +108,7 @@ var hyperHTML = (function (document) {
106
108
if ( isSelect && noSelection && child . selected ) {
107
109
noSelection = ! noSelection ;
108
110
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 ) ;
110
112
}
111
113
112
114
start ++ ;
@@ -118,7 +120,7 @@ var hyperHTML = (function (document) {
118
120
var identity = function identity ( O ) {
119
121
return O ;
120
122
} ;
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 ) {
122
124
var length = lessEnd - lessStart ;
123
125
/* istanbul ignore if */
124
126
@@ -432,7 +434,7 @@ var hyperHTML = (function (document) {
432
434
var i = - 1 ; // 2 simple indels: the shortest sequence is a subsequence of the longest
433
435
434
436
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
436
438
437
439
if ( - 1 < i ) {
438
440
append ( get , parentNode , futureNodes , futureStart , i , get ( currentNodes [ currentStart ] , 0 ) ) ;
@@ -442,7 +444,7 @@ var hyperHTML = (function (document) {
442
444
}
443
445
/* istanbul ignore else */
444
446
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
446
448
447
449
if ( - 1 < i ) {
448
450
remove ( get , currentNodes , currentStart , i ) ;
@@ -761,7 +763,7 @@ var hyperHTML = (function (document) {
761
763
762
764
var FRAGMENT = 'fragment' ;
763
765
var TEMPLATE = 'template' ;
764
- var HAS_CONTENT = 'content' in create ( TEMPLATE ) ;
766
+ var HAS_CONTENT = ( 'content' in create ( TEMPLATE ) ) ;
765
767
var createHTML = HAS_CONTENT ? function ( html ) {
766
768
var template = create ( TEMPLATE ) ;
767
769
template . innerHTML = html ;
@@ -907,7 +909,7 @@ var hyperHTML = (function (document) {
907
909
908
910
/*! (c) Andrea Giammarchi - ISC */
909
911
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:
911
913
// it "forgets" empty childNodes. This feature-detects that.
912
914
913
915
@@ -980,6 +982,22 @@ var hyperHTML = (function (document) {
980
982
return VOID_ELEMENTS . test ( $1 ) ? $0 : '<' + $1 + $2 + '></' + $1 + '>' ;
981
983
}
982
984
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
+
983
1001
/* istanbul ignore next */
984
1002
985
1003
var normalizeAttributes = UID_IE ? function ( attributes , parts ) {
@@ -1173,7 +1191,7 @@ var hyperHTML = (function (document) {
1173
1191
}
1174
1192
1175
1193
// globals
1176
- var parsed = new WeakMap$1 ( ) ;
1194
+ var parsed = umap ( new WeakMap$1 ( ) ) ;
1177
1195
1178
1196
function createInfo ( options , template ) {
1179
1197
var markup = ( options . convert || sanitize ) ( template ) ;
@@ -1183,7 +1201,7 @@ var hyperHTML = (function (document) {
1183
1201
cleanContent ( content ) ;
1184
1202
var holes = [ ] ;
1185
1203
parse ( content , holes , template . slice ( 0 ) , [ ] ) ;
1186
- var info = {
1204
+ return {
1187
1205
content : content ,
1188
1206
updates : function updates ( content ) {
1189
1207
var updates = [ ] ;
@@ -1262,12 +1280,10 @@ var hyperHTML = (function (document) {
1262
1280
} ;
1263
1281
}
1264
1282
} ;
1265
- parsed . set ( template , info ) ;
1266
- return info ;
1267
1283
}
1268
1284
1269
1285
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 ) ) ;
1271
1287
return info . updates ( importNode . call ( document , info . content , true ) ) ;
1272
1288
}
1273
1289
@@ -1530,7 +1546,7 @@ var hyperHTML = (function (document) {
1530
1546
// so that you can style=${{width: 120}}. In this case, the behavior has been
1531
1547
// fully inspired by Preact library and its simplicity.
1532
1548
attribute : function attribute ( node , name , original ) {
1533
- var isSVG = OWNER_SVG_ELEMENT in node ;
1549
+ var isSVG = ( OWNER_SVG_ELEMENT in node ) ;
1534
1550
var oldValue ; // if the attribute is the style one
1535
1551
// handle it differently from others
1536
1552
0 commit comments