File tree 2 files changed +20
-14
lines changed 2 files changed +20
-14
lines changed Original file line number Diff line number Diff line change @@ -2075,6 +2075,11 @@ $.extend(Selectize.prototype, {
2075
2075
self . $control_input . removeData ( 'grow' ) ;
2076
2076
self . $input . removeData ( 'selectize' ) ;
2077
2077
2078
+ if ( -- Selectize . count == 0 && Selectize . $testInput ) {
2079
+ Selectize . $testInput . remove ( ) ;
2080
+ Selectize . $testInput = undefined ;
2081
+ }
2082
+
2078
2083
$ ( window ) . off ( eventNS ) ;
2079
2084
$ ( document ) . off ( eventNS ) ;
2080
2085
$ ( document . body ) . off ( eventNS ) ;
Original file line number Diff line number Diff line change @@ -235,27 +235,28 @@ var measureString = function(str, $parent) {
235
235
return 0 ;
236
236
}
237
237
238
- var $test = $ ( '<test>' ) . css ( {
239
- position : 'absolute' ,
240
- top : - 99999 ,
241
- left : - 99999 ,
242
- width : 'auto' ,
243
- padding : 0 ,
244
- whiteSpace : 'pre'
245
- } ) . text ( str ) . appendTo ( 'body' ) ;
246
-
247
- transferStyles ( $parent , $test , [
238
+ if ( ! Selectize . $testInput ) {
239
+ Selectize . $testInput = $ ( '<span />' ) . css ( {
240
+ position : 'absolute' ,
241
+ top : - 99999 ,
242
+ left : - 99999 ,
243
+ width : 'auto' ,
244
+ padding : 0 ,
245
+ whiteSpace : 'pre'
246
+ } ) . appendTo ( 'body' ) ;
247
+ }
248
+
249
+ Selectize . $testInput . text ( str ) ;
250
+
251
+ transferStyles ( $parent , Selectize . $testInput , [
248
252
'letterSpacing' ,
249
253
'fontSize' ,
250
254
'fontFamily' ,
251
255
'fontWeight' ,
252
256
'textTransform'
253
257
] ) ;
254
258
255
- var width = $test . width ( ) ;
256
- $test . remove ( ) ;
257
-
258
- return width ;
259
+ return Selectize . $testInput . width ( ) ;
259
260
} ;
260
261
261
262
/**
You can’t perform that action at this time.
0 commit comments