File tree Expand file tree Collapse file tree 6 files changed +55
-6
lines changed Expand file tree Collapse file tree 6 files changed +55
-6
lines changed Original file line number Diff line number Diff line change @@ -643,6 +643,18 @@ pub const PendingScript = struct {
643643 // if async isn't known, it'll fallback to defer.
644644
645645 const script = & self .script ;
646+
647+ // Module scripts are deferred by default.
648+ // https://v8.dev/features/modules#defer
649+ if (script .kind == .module ) {
650+ return & self .manager .deferreds ;
651+ }
652+
653+ // Script is not a module but inline, we ignore async/defer properties.
654+ if (script .source == .@"inline" ) {
655+ return & self .manager .scripts ;
656+ }
657+
646658 if (script .is_async ) {
647659 return & self .manager .asyncs ;
648660 }
@@ -651,12 +663,6 @@ pub const PendingScript = struct {
651663 return & self .manager .deferreds ;
652664 }
653665
654- // Module scripts are deferred by default.
655- // https://v8.dev/features/modules#defer
656- if (script .kind == .module ) {
657- return & self .manager .deferreds ;
658- }
659-
660666 return & self .manager .scripts ;
661667 }
662668};
Original file line number Diff line number Diff line change @@ -1350,6 +1350,7 @@ test "Browser: HTML.HtmlScriptElement" {
13501350 try testing .htmlRunner ("html/script/import.html" );
13511351 try testing .htmlRunner ("html/script/dynamic_import.html" );
13521352 try testing .htmlRunner ("html/script/importmap.html" );
1353+ try testing .htmlRunner ("html/script/order.html" );
13531354}
13541355
13551356test "Browser: HTML.HtmlSlotElement" {
Original file line number Diff line number Diff line change 1+ <!DOCTYPE html>
2+ < script src ="../../testing.js "> </ script >
3+
4+ < script defer id ="remote_defer " src ="order_defer.js "> </ script >
5+ < script defer id ="remote_async " src ="order_async.js "> </ script >
6+
7+ < script type =module id ="inline_module ">
8+ // inline module is always deferred.
9+ list += 'g' ;
10+ testing . expectEqual ( 'abcdefg' , list ) ;
11+ </ script >
12+
13+ < script >
14+ var list = '' ;
15+ </ script >
16+
17+ < script id ="remote " src ="order.js "> </ script >
18+
19+ < script async id ="inline_async ">
20+ // inline script ignore async
21+ list += 'b' ;
22+ testing . expectEqual ( 'ab' , list ) ;
23+ </ script >
24+
25+ < script defer id ="inline_defer ">
26+ // inline script ignore defer
27+ list += 'c' ;
28+ testing . expectEqual ( 'abc' , list ) ;
29+ </ script >
30+
31+ < script id ="default ">
32+ // simple inline script
33+ list += 'd' ;
34+ testing . expectEqual ( 'abcd' , list ) ;
35+ </ script >
Original file line number Diff line number Diff line change 1+ list += 'a' ;
2+ testing . expectEqual ( 'a' , list ) ;
Original file line number Diff line number Diff line change 1+ list += 'f' ;
2+ testing . expectEqual ( 'abcdef' , list ) ;
3+
Original file line number Diff line number Diff line change 1+ list += 'e' ;
2+ testing . expectEqual ( 'abcde' , list ) ;
You can’t perform that action at this time.
0 commit comments