@@ -101,33 +101,27 @@ fn main {
101101
102102 // Demonstrate getAttribute
103103 let heading_id = heading .get_attribute ("id" )
104- match heading_id {
105- Some (id ) => {
106- let info : @webapi .HTMLDivElement = @webapi .document
107- .create_element ("div" )
108- .into ()
109- info
110- ..set_attribute (
111- "style" , "margin: 0.5em 0; color: gray; font-size: 0.9em;" ,
112- )
113- .set_text_content ("Heading id attribute: " + id )
104+ guard heading_id is Some (id ) else { () }
105+ let info : @webapi .HTMLDivElement = @webapi .document
106+ .create_element ("div" )
107+ .into ()
108+ info
109+ ..set_attribute ("style" , "margin: 0.5em 0; color: gray; font-size: 0.9em;" )
110+ .set_text_content ("Heading id attribute: " + id )
114111
115- // Build the DOM tree
116- let app = @webapi .document.get_element_by_id ("app" ).unwrap ()
117- let container : @webapi .HTMLDivElement = @webapi .document
118- .create_element ("div" )
119- .into ()
120- container .set_attribute (
121- "style" , "font-family: system-ui; max-width: 600px; margin: 2em auto;" ,
122- )
123- let children : Array [& @webapi .TNode ] = [
124- heading , info , list , status , add_btn , remove_btn , clone_btn ,
125- ]
126- for child in children {
127- container .append_child (child ) |> ignore
128- }
129- let _ = app .append_child (container )
130- }
131- None => ()
112+ // Build the DOM tree
113+ let app = @webapi .document.get_element_by_id ("app" ).unwrap ()
114+ let container : @webapi .HTMLDivElement = @webapi .document
115+ .create_element ("div" )
116+ .into ()
117+ container .set_attribute (
118+ "style" , "font-family: system-ui; max-width: 600px; margin: 2em auto;" ,
119+ )
120+ let children : Array [& @webapi .TNode ] = [
121+ heading , info , list , status , add_btn , remove_btn , clone_btn ,
122+ ]
123+ for child in children {
124+ container .append_child (child ) |> ignore
132125 }
126+ let _ = app .append_child (container )
133127}
0 commit comments