This is an automated email from the ASF dual-hosted git repository.

thiagohp pushed a commit to branch feature/requirejs-less
in repository https://gitbox.apache.org/repos/asf/tapestry-5.git

commit 92e236a39b581a00b3f0236470f4ed393b5caf2e
Author: Thiago H. de Paula Figueiredo <[email protected]>
AuthorDate: Sun Aug 3 10:49:50 2025 -0300

    In which we discover HTML is too flexible
---
 .../services/javascript/EsModuleManagerImpl.java         | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git 
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/EsModuleManagerImpl.java
 
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/EsModuleManagerImpl.java
index de8e9982f..6c5f17a47 100644
--- 
a/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/EsModuleManagerImpl.java
+++ 
b/tapestry-core/src/main/java/org/apache/tapestry5/internal/services/javascript/EsModuleManagerImpl.java
@@ -239,6 +239,14 @@ public class EsModuleManagerImpl implements EsModuleManager
                 if (head == null) 
                 {
                     head = root.find("head");
+                    // I think it's quite ugly, but HTML doesn't require
+                    // <head>, <body> nor even <html> itself. In this case,
+                    // if <head> isn't found, we just add the element to 
+                    // the root element.
+                    if (head == null)
+                    {
+                        head = root;
+                    }
                 }
                 script = head.element("script");
             }
@@ -246,6 +254,14 @@ public class EsModuleManagerImpl implements EsModuleManager
                 if (body == null)
                 {
                     body = root.find("body");
+                    // I think it's quite ugly, but HTML doesn't require
+                    // <head>, <body> nor even <html> itself. In this case,
+                    // if <body> isn't found, we just add the element to 
+                    // the root element.
+                    if (body == null)
+                    {
+                        body = root;
+                    }
                 }
                 if (placement.equals(ImportPlacement.BODY_BOTTOM)) {
                     script = body.element("script");

Reply via email to