When testing our application running on Mojarra 2.1.10 I found out that the generated HTML does not contain the doctype, even though it is present in the template. Missing doctype of course means quirk mode in browsers causing layout issues. The problematic page does not use the template directly, but instead it includes another page that then uses the template.
I tried the application with multiple Mojarra versions:
2.0.6 - no problem, doctype rendered
2.1.7 - no problem, doctype rendered
2.1.8 - doctype missing, root html tag missing
2.1.10 - doctype missing, html tag present
The problematic page (home.xhtml) contains just one ui:include tag that includes another page (todos.xhtml) which uses a template (through ui:composition) to include the main layout stuff (including the doctype). If I visit home.jsf as the first JSF page after the server starts, none of the pages using the same template will contain the doctype. But if I visit todos.jsf first, the doctype will be present also when I open home.jsf subsequently.
I had a look in com.sun.faces.facelets.compiler.SAXCompiler (startDTD() within CompilationHandler) and it seems that this behaviour is present since
JAVASERVERFACES-2328 was fixed. Obviously the decision whether the doctype will be rendered or not is decided when the template facelet is compiled, depending on whether this facelet is used within an ui:include tag or not. In our case however the template is used both from within a ui:include tag (the home.jsf case) and directly (todos.jsf) and the doctype presence depends on which page is accessed first.