File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -83,6 +83,13 @@ let render_to_string ~mode element =
8383      when  Html. is_self_closing_tag tag ->
8484        is_root.contents < -  false ;
8585        Printf. sprintf " <%s%s />"   tag (attributes_to_string attributes)
86+     |  Lower_case_element  { tag; attributes; children }
87+       when  String. equal tag " html"   ->
88+         is_root.contents < -  false ;
89+         Printf. sprintf " <!DOCTYPE html><%s%s>%s</%s>"   tag
90+           (attributes_to_string attributes)
91+           (children |>  List. map render_element |>  String. concat " "  )
92+           tag
8693    |  Lower_case_element  { tag; attributes; children }  ->
8794        is_root.contents < -  false ;
8895        Printf. sprintf " <%s%s>%s</%s>"   tag
Original file line number Diff line number Diff line change @@ -5,6 +5,12 @@ let single_empty_tag () =
55  let  div =  React. createElement " div"   []  []  in 
66  assert_string (ReactDOM. renderToStaticMarkup div) " <div></div>" 
77
8+ let  html_doctype  ()  = 
9+   let  app =  React. createElement " html"   []  []  in 
10+   assert_string
11+     (ReactDOM. renderToStaticMarkup app)
12+     " <!DOCTYPE html><html></html>" 
13+ 
814let  empty_string_attribute  ()  = 
915  let  div =  React. createElement " div"   [ React.JSX. String  (" class"  , " "  ) ] []  in 
1016  assert_string (ReactDOM. renderToStaticMarkup div) " <div class=\"\" ></div>" 
@@ -321,6 +327,7 @@ let case title fn = Alcotest_lwt.test_case_sync title `Quick fn
321327let  tests = 
322328  ( " renderToStaticMarkup"  ,
323329    [
330+       case " html_doctype"   html_doctype;
324331      case " single_empty_tag"   single_empty_tag;
325332      case " empty_string_attribute"   empty_string_attribute;
326333      case " bool_attributes"   bool_attributes;
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments