File tree Expand file tree Collapse file tree 2 files changed +22
-3
lines changed
Expand file tree Collapse file tree 2 files changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -39,14 +39,33 @@ async function sleep(ms) {
3939 return new Promise ( ( resolve ) => setTimeout ( resolve , ms ) ) ;
4040}
4141
42- ( async ( ) => {
42+ async function run ( fn ) {
43+ try {
44+ await fn ( ) ;
45+ } catch ( err ) {
46+ console . warn ( 'Error in main function:' , err ) ;
47+ }
48+ }
49+
50+ run ( async ( ) => {
4351 await sleep ( 1000 ) ;
4452 const some = document . createElement ( 'div' ) ;
4553 some . style . setProperty ( 'width' , '100px' ) ;
4654 some . style . setProperty ( 'height' , '100px' ) ;
4755 some . style . setProperty ( 'background-color' , 'red' ) ;
4856 document . body . appendChild ( some ) ;
4957
58+ // test append style
59+ await sleep ( 1000 ) ;
60+ const style = document . createElement ( 'style' ) ;
61+ const cssSource = document . createTextNode ( `
62+ body {
63+ background-color: lightgray;
64+ }
65+ ` ) ;
66+ style . appendChild ( cssSource ) ;
67+ document . head . appendChild ( style ) ;
68+
5069 await sleep ( 1000 ) ;
5170 const bar = document . createElement ( 'div' ) ;
5271 bar . style . width = '100px' ;
@@ -68,4 +87,4 @@ async function sleep(ms) {
6887 // '<div style="width:100px;height:100px;background-color:blue;font-size:30px;color:#fff">'
6988 // + 'foobar'
7089 // + '</div>';
71- } ) ( ) ;
90+ } ) ;
Original file line number Diff line number Diff line change @@ -32,6 +32,6 @@ namespace dom
3232
3333 // Update the sheet
3434 sheet_ = sheet;
35- getOwnerDocumentChecked ().styleSheets_ . push_back (sheet);
35+ getOwnerDocumentChecked ().appendStyleSheet (sheet);
3636 }
3737}
You can’t perform that action at this time.
0 commit comments