File tree Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Expand file tree Collapse file tree 1 file changed +14
-12
lines changed Original file line number Diff line number Diff line change 3636 }
3737 } ;
3838
39- // Register page load & unload events
40- if ( $ ) {
41- $ ( mountReactComponents ) ;
42- $ ( window ) . unload ( unmountReactComponents ) ;
43- } else {
44- document . addEventListener ( 'DOMContentLoaded' , mountReactComponents ) ;
45- window . addEventListener ( 'unload' , unmountReactComponents ) ;
46- }
47-
48- // Turbolinks specified events
49- if ( typeof Turbolinks !== 'undefined' ) {
39+ var handleTurbolinksEvents = function ( ) {
5040 var handleEvent ;
5141 if ( $ ) {
5242 handleEvent = function ( eventName , callback ) {
5949 }
6050 handleEvent ( 'page:change' , mountReactComponents ) ;
6151 handleEvent ( 'page:before-change' , unmountReactComponents ) ;
62- }
52+ } ;
53+
54+ var handleNativeEvents = function ( ) {
55+ if ( $ ) {
56+ $ ( mountReactComponents ) ;
57+ $ ( window ) . unload ( unmountReactComponents ) ;
58+ } else {
59+ document . addEventListener ( 'DOMContentLoaded' , mountReactComponents ) ;
60+ window . addEventListener ( 'unload' , unmountReactComponents ) ;
61+ }
62+ } ;
63+
64+ typeof Turbolinks !== 'undefined' ? handleTurbolinksEvents ( ) : handleNativeEvents ( ) ;
6365} ) ( document , window , React ) ;
You can’t perform that action at this time.
0 commit comments