File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed
packages/svelte/tests/runtime-browser/samples/head-scripts Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Original file line number Diff line number Diff line change
1
+ import { test } from '../../assert' ;
2
+
3
+ export default test ( {
4
+ mode : [ 'client' ] ,
5
+ async test ( { assert, window } ) {
6
+ // wait the script to load (maybe there a better way)
7
+ await new Promise ( ( resolve ) => setTimeout ( resolve , 1 ) ) ;
8
+ assert . htmlEqual (
9
+ window . document . body . innerHTML ,
10
+ `<main><b id="r1">1</b><b id="r2">2</b><b id="r3">3</b></main>`
11
+ ) ;
12
+ }
13
+ } ) ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ function jssrc (src ) {
3
+ return ' data:text/javascript;base64, ' + btoa (src);
4
+ }
5
+
6
+ const scriptSrcs = [ 1 , 2 , 3 ]
7
+ .map (n => jssrc (` document.getElementById('r${ n} ').innerText = '${ n} ';` ));
8
+ </script >
9
+
10
+ <svelte:head >
11
+ {#each scriptSrcs as src }
12
+ <script src ={src } async defer ></script >
13
+ {/each }
14
+ </svelte:head >
15
+
16
+ <b id =" r1" >?</b ><b id =" r2" >?</b ><b id =" r3" >?</b >
You can’t perform that action at this time.
0 commit comments