File tree Expand file tree Collapse file tree 2 files changed +20
-14
lines changed
Expand file tree Collapse file tree 2 files changed +20
-14
lines changed Original file line number Diff line number Diff line change @@ -2075,6 +2075,11 @@ $.extend(Selectize.prototype, {
20752075 self . $control_input . removeData ( 'grow' ) ;
20762076 self . $input . removeData ( 'selectize' ) ;
20772077
2078+ if ( -- Selectize . count == 0 && Selectize . $testInput ) {
2079+ Selectize . $testInput . remove ( ) ;
2080+ Selectize . $testInput = undefined ;
2081+ }
2082+
20782083 $ ( window ) . off ( eventNS ) ;
20792084 $ ( document ) . off ( eventNS ) ;
20802085 $ ( document . body ) . off ( eventNS ) ;
Original file line number Diff line number Diff line change @@ -235,27 +235,28 @@ var measureString = function(str, $parent) {
235235 return 0 ;
236236 }
237237
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 , [
248252 'letterSpacing' ,
249253 'fontSize' ,
250254 'fontFamily' ,
251255 'fontWeight' ,
252256 'textTransform'
253257 ] ) ;
254258
255- var width = $test . width ( ) ;
256- $test . remove ( ) ;
257-
258- return width ;
259+ return Selectize . $testInput . width ( ) ;
259260} ;
260261
261262/**
You can’t perform that action at this time.
0 commit comments