File tree Expand file tree Collapse file tree
packages/integrations/turbolinks Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -2,9 +2,17 @@ import Turbolinks from 'turbolinks';
22export { Turbolinks } ;
33
44// Before every page navigation, remove any previously added component hydration scripts
5- document . addEventListener ( "turbolinks:before-render" , function ( ) {
6- const scripts = document . querySelectorAll ( "script[data-astro-component-hydration]" ) ;
7- for ( const script of scripts ) {
8- script . remove ( ) ;
9- }
10- } )
5+ document . addEventListener ( 'turbolinks:before-render' , function ( ) {
6+ const scripts = document . querySelectorAll ( 'script[data-astro-component-hydration]' ) ;
7+ for ( const script of scripts ) {
8+ script . remove ( ) ;
9+ }
10+ } ) ;
11+
12+ // After every page navigation, move the bundled styles into the body
13+ document . addEventListener ( 'turbolinks:render' , function ( ) {
14+ const styles = document . querySelectorAll ( 'link[href^="/assets/asset"][href$=".css"]' ) ;
15+ for ( const style of styles ) {
16+ document . body . append ( style ) ;
17+ }
18+ } ) ;
You can’t perform that action at this time.
0 commit comments