File tree Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Expand file tree Collapse file tree 2 files changed +38
-2
lines changed Original file line number Diff line number Diff line change 45
45
src = $ ( 'script:last' ) . attr ( 'src' ) ,
46
46
document = window . document ; // local variable is always faster to access then a global
47
47
48
+ var setImmediate = window . setImmediate ;
49
+ var Promise = window . Promise ;
50
+ if ( ! setImmediate && Promise ) {
51
+ // Good enough approximation of setImmediate
52
+ setImmediate = function ( cb , arg ) {
53
+ Promise . resolve ( arg ) . then ( cb ) ;
54
+ } ;
55
+ }
56
+
48
57
/**
49
58
* holds all jstree related functions and variables, including the actual class and methods to create, access and manipulate instances.
50
59
* @name $.jstree
1935
1944
if ( rslt . add . length ) {
1936
1945
this . trigger ( 'changed' , { 'action' : 'model' , 'selected' : this . _data . core . selected } ) ;
1937
1946
}
1938
- cb . call ( this , true ) ;
1947
+
1948
+ // If no worker, try to mimic worker behavioour, by invoking cb asynchronously
1949
+ if ( ! worker && setImmediate ) {
1950
+ setImmediate ( function ( ) {
1951
+ cb . call ( inst , true ) ;
1952
+ } ) ;
1953
+ }
1954
+ else {
1955
+ cb . call ( inst , true ) ;
1956
+ }
1939
1957
} ;
1940
1958
if ( this . settings . core . worker && window . Blob && window . URL && window . Worker ) {
1941
1959
try {
Original file line number Diff line number Diff line change 45
45
src = $ ( 'script:last' ) . attr ( 'src' ) ,
46
46
document = window . document ; // local variable is always faster to access then a global
47
47
48
+ var setImmediate = window . setImmediate ;
49
+ var Promise = window . Promise ;
50
+ if ( ! setImmediate && Promise ) {
51
+ // Good enough approximation of setImmediate
52
+ setImmediate = function ( cb , arg ) {
53
+ Promise . resolve ( arg ) . then ( cb ) ;
54
+ } ;
55
+ }
56
+
48
57
/**
49
58
* holds all jstree related functions and variables, including the actual class and methods to create, access and manipulate instances.
50
59
* @name $.jstree
1935
1944
if ( rslt . add . length ) {
1936
1945
this . trigger ( 'changed' , { 'action' : 'model' , 'selected' : this . _data . core . selected } ) ;
1937
1946
}
1938
- cb . call ( this , true ) ;
1947
+
1948
+ // If no worker, try to mimic worker behavioour, by invoking cb asynchronously
1949
+ if ( ! worker && setImmediate ) {
1950
+ setImmediate ( function ( ) {
1951
+ cb . call ( inst , true ) ;
1952
+ } ) ;
1953
+ }
1954
+ else {
1955
+ cb . call ( inst , true ) ;
1956
+ }
1939
1957
} ;
1940
1958
if ( this . settings . core . worker && window . Blob && window . URL && window . Worker ) {
1941
1959
try {
You can’t perform that action at this time.
0 commit comments