File tree Expand file tree Collapse file tree 3 files changed +23
-10
lines changed Expand file tree Collapse file tree 3 files changed +23
-10
lines changed Original file line number Diff line number Diff line change
1
+ ---
2
+ ' @sveltejs/kit ' : patch
3
+ ---
4
+
5
+ fix: always include ` <link rel="stylesheet"> ` , even for stylesheets excluded from Link headers
Original file line number Diff line number Diff line change @@ -235,20 +235,20 @@ export async function render_response({
235
235
for ( const dep of stylesheets ) {
236
236
const path = prefixed ( dep ) ;
237
237
238
- if ( resolve_opts . preload ( { type : 'css' , path } ) ) {
239
- const attributes = [ 'rel="stylesheet"' ] ;
240
-
241
- if ( inline_styles . has ( dep ) ) {
242
- // don't load stylesheets that are already inlined
243
- // include them in disabled state so that Vite can detect them and doesn't try to add them
244
- attributes . push ( 'disabled' , 'media="(max-width: 0)"' ) ;
245
- } else {
238
+ const attributes = [ 'rel="stylesheet"' ] ;
239
+
240
+ if ( inline_styles . has ( dep ) ) {
241
+ // don't load stylesheets that are already inlined
242
+ // include them in disabled state so that Vite can detect them and doesn't try to add them
243
+ attributes . push ( ' disabled' , 'media="(max-width: 0)"' ) ;
244
+ } else {
245
+ if ( resolve_opts . preload ( { type : 'css' , path } ) ) {
246
246
const preload_atts = [ 'rel="preload"' , 'as="style"' ] ;
247
247
link_header_preloads . add ( `<${ encodeURI ( path ) } >; ${ preload_atts . join ( ';' ) } ; nopush` ) ;
248
248
}
249
-
250
- head += `\n\t\t<link href="${ path } " ${ attributes . join ( ' ' ) } >` ;
251
249
}
250
+
251
+ head += `\n\t\t<link href="${ path } " ${ attributes . join ( ' ' ) } >` ;
252
252
}
253
253
254
254
for ( const dep of fonts ) {
Original file line number Diff line number Diff line change
1
+ /** @type {import('@sveltejs/kit').Handle } */
2
+ export function handle ( { event, resolve } ) {
3
+ return resolve ( event , {
4
+ // this allows us to check that <link rel="stylesheet"> is still added
5
+ // to the DOM even if they're not included by `preload`
6
+ preload : ( { type } ) => type !== 'css'
7
+ } ) ;
8
+ }
You can’t perform that action at this time.
0 commit comments