You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2008/11/26 01:47:21 UTC

svn commit: r720686 - in /tapestry/tapestry5/trunk: src/site/apt/guide/ tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/ tapestry-core/src/main/java/org/apache/tapestry5/dom/ tapestry-core/src/test/java/org/apache/tapestry5/corelib/...

Author: hlship
Date: Tue Nov 25 16:47:21 2008
New Revision: 720686

URL: http://svn.apache.org/viewvc?rev=720686&view=rev
Log:
TAP5-385: Tapestry 5 renders an HTML output often renders empty elements incorrect
TAP5-381: Documentation talks about a "tapestry.charset" when there's no such configuration documented

Modified:
    tapestry/tapestry5/trunk/src/site/apt/guide/conf.apt
    tapestry/tapestry5/trunk/src/site/apt/guide/content-type.apt
    tapestry/tapestry5/trunk/src/site/apt/guide/templates.apt
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/dom/DefaultMarkupModel.java
    tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/dom/EndTagStyle.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/OutputTest.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/MarkupWriterImplTest.java
    tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/dom/document_with_root_element_and_attributes.txt
    tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/dom/nested_elements.txt

Modified: tapestry/tapestry5/trunk/src/site/apt/guide/conf.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/src/site/apt/guide/conf.apt?rev=720686&r1=720685&r2=720686&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/src/site/apt/guide/conf.apt (original)
+++ tapestry/tapestry5/trunk/src/site/apt/guide/conf.apt Tue Nov 25 16:47:21 2008
@@ -103,6 +103,9 @@
   Many of these symbols have an associated constant in the class
   {{{../apidocs/org/apache/tapestry5/SymbolConstants.html}SymbolConstants}}.
 
+  [tapestry.charset]
+    The character encoding used when generating output (or parsing input).  The default is "UTF-8".
+
   [tapestry.compress-whitespace]
     A flag (true or false).  When true (the default) whitespace in component templates is compressed by default
     (this can be fine-tuned using the standard xml:space attribute on an element in the template).

Modified: tapestry/tapestry5/trunk/src/site/apt/guide/content-type.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/src/site/apt/guide/content-type.apt?rev=720686&r1=720685&r2=720686&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/src/site/apt/guide/content-type.apt (original)
+++ tapestry/tapestry5/trunk/src/site/apt/guide/content-type.apt Tue Nov 25 16:47:21 2008
@@ -8,20 +8,16 @@
 
   * The \<?xml\?> XML declaration is omitted.
 
-  * Certain elements will render as an open and close tag, even if the body is empty:
+  * Most element render with an open and close tag, even if empty.
 
-    * script
+  * Certain elements will be abbreviated to just the open tag, if empty:
 
-    * div
+    * br
 
-    * span
-
-    * p
-
-    * textarea
-
-    * select
+    * hr
 
+    * img
+   
     []
 
   * \<![CDATA[]\> sections are <<not>> used

Modified: tapestry/tapestry5/trunk/src/site/apt/guide/templates.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/src/site/apt/guide/templates.apt?rev=720686&r1=720685&r2=720686&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/src/site/apt/guide/templates.apt (original)
+++ tapestry/tapestry5/trunk/src/site/apt/guide/templates.apt Tue Nov 25 16:47:21 2008
@@ -323,8 +323,8 @@
   . . .
 ---
 
-  In other words, the path, <code>ajax</code>, from the namespace URI takes the place of the path prefixes <code>ajax.</code>
-  seen in the first element, or <code>ajax/</code> seen in the second.  As far as Tapestry is concerned, they are all
+  In other words, the path, <<<ajax>>>, from the namespace URI takes the place of the path prefixes <<<ajax.>>>
+  seen in the first element, or <<<ajax/>>> seen in the second.  As far as Tapestry is concerned, they are all
   equivalent.
 
    

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java?rev=720686&r1=720685&r2=720686&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/corelib/components/Form.java Tue Nov 25 16:47:21 2008
@@ -197,7 +197,6 @@
 
     private ComponentActionSink actionSink;
 
-    @SuppressWarnings("unused")
     @Mixin
     private RenderInformals renderInformals;
 

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/dom/DefaultMarkupModel.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/dom/DefaultMarkupModel.java?rev=720686&r1=720685&r2=720686&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/dom/DefaultMarkupModel.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/dom/DefaultMarkupModel.java Tue Nov 25 16:47:21 2008
@@ -20,23 +20,19 @@
 
 /**
  * Default implementation of {@link org.apache.tapestry5.dom.MarkupModel} that is appropriate for traditional (X)HTML
- * markup. Assumes that all tags are lower-case.  A certain set of tags will always be expanded (with seperate begin and
- * end tags) even if their content is empty: script, div, span, p, textarea, select, label; this is for compatibility
- * with web browsers, especially when the content type of a response indicates HTML, not true XML.
+ * markup. Assumes that all tags are lower-case.  The majority of elements will be "expanded" (meaning a complete start
+ * and end tag); this is for compatibility with web browsers, especially when the content type of a response indicates
+ * HTML, not true XML. Only the "hr" and "br" and "img" tags will be rendered abbreviated (i.e., "lt;img/&gt;").
  */
 public class DefaultMarkupModel extends AbstractMarkupModel
 {
-    /**
-     * For these tags, use {@link org.apache.tapestry5.dom.EndTagStyle#REQUIRE}.
-     */
-    private final Set<String> REQUIRE_END_TAG =
-            CollectionFactory.newSet("script", "div", "span", "p", "textarea", "select", "label");
+    private final Set<String> ALWAYS_EMPTY = CollectionFactory.newSet("hr", "br", "img");
 
     public EndTagStyle getEndTagStyle(String element)
     {
-        boolean required = REQUIRE_END_TAG.contains(element);
+        boolean alwaysEmpty = ALWAYS_EMPTY.contains(element);
 
-        return required ? EndTagStyle.REQUIRE : EndTagStyle.ABBREVIATE;
+        return alwaysEmpty ? EndTagStyle.ABBREVIATE : EndTagStyle.REQUIRE;
     }
 
     /**

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/dom/EndTagStyle.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/dom/EndTagStyle.java?rev=720686&r1=720685&r2=720686&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/dom/EndTagStyle.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/java/org/apache/tapestry5/dom/EndTagStyle.java Tue Nov 25 16:47:21 2008
@@ -34,7 +34,7 @@
     REQUIRE,
     /**
      * Require an end tag, but abbreviate it if the element has no children. This is the only value that should be used
-     * in XML documents, but {@link org.apache.tapestry5.dom.DefaultMarkupModel} forces certain tags to use {@link
+     * in XML documents, but {@link org.apache.tapestry5.dom.DefaultMarkupModel} forces most tags to use {@link
      * #REQUIRE} for semi-obscure browser compatibility issues.
      */
     ABBREVIATE

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/OutputTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/OutputTest.java?rev=720686&r1=720685&r2=720686&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/OutputTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/OutputTest.java Tue Nov 25 16:47:21 2008
@@ -124,7 +124,7 @@
 
         verify();
 
-        assertEquals(writer.toString(), "<root/>");
+        assertEquals(writer.toString(), "<root></root>");
     }
 
     @Test
@@ -189,6 +189,6 @@
 
         verify();
 
-        assertEquals(writer.toString(), "<root/>");
+        assertEquals(writer.toString(), "<root></root>");
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java?rev=720686&r1=720685&r2=720686&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java Tue Nov 25 16:47:21 2008
@@ -30,7 +30,7 @@
 
         d.newRootElement("empty");
 
-        assertEquals(d.toString(), "<empty/>");
+        assertEquals(d.toString(), "<empty></empty>");
     }
 
     @Test
@@ -169,7 +169,7 @@
 
         e.attribute("foo", "bar");
 
-        final String expected = "<root foo=\"bar\"/>";
+        final String expected = "<root foo=\"bar\"></root>";
 
         assertEquals(d.toString(), expected);
 
@@ -229,7 +229,7 @@
 
         e.element("foo", "alpha", "legion");
 
-        assertEquals(d.toString(), "<root><foo alpha=\"legion\"/></root>");
+        assertEquals(d.toString(), "<root><foo alpha=\"legion\"></foo></root>");
     }
 
     @Test
@@ -482,13 +482,13 @@
         mobile.text("On the move");
 
         assertEquals(d.toString(),
-                     "<doc><placeholder/><target/><source><mobile>On the move</mobile></source></doc>");
+                     "<doc><placeholder></placeholder><target></target><source><mobile>On the move</mobile></source></doc>");
 
 
         mobile.moveBefore(target);
 
         assertEquals(d.toString(),
-                     "<doc><placeholder/><mobile>On the move</mobile><target/><source/></doc>");
+                     "<doc><placeholder></placeholder><mobile>On the move</mobile><target></target><source></source></doc>");
     }
 
     @Test
@@ -505,13 +505,13 @@
         mobile.text("On the move");
 
         assertEquals(d.toString(),
-                     "<doc><placeholder/><target/><source><mobile>On the move</mobile></source></doc>");
+                     "<doc><placeholder></placeholder><target></target><source><mobile>On the move</mobile></source></doc>");
 
 
         mobile.moveAfter(target);
 
         assertEquals(d.toString(),
-                     "<doc><placeholder/><target/><mobile>On the move</mobile><source/></doc>");
+                     "<doc><placeholder></placeholder><target></target><mobile>On the move</mobile><source></source></doc>");
     }
 
     @Test
@@ -528,12 +528,12 @@
         mobile.text("On the move");
 
         assertEquals(d.toString(),
-                     "<doc><target><placeholder/></target><source><mobile>On the move</mobile></source></doc>");
+                     "<doc><target><placeholder></placeholder></target><source><mobile>On the move</mobile></source></doc>");
 
         mobile.moveToTop(target);
 
         assertEquals(d.toString(),
-                     "<doc><target><mobile>On the move</mobile><placeholder/></target><source/></doc>");
+                     "<doc><target><mobile>On the move</mobile><placeholder></placeholder></target><source></source></doc>");
     }
 
     @Test
@@ -550,12 +550,12 @@
         mobile.text("On the move");
 
         assertEquals(d.toString(),
-                     "<doc><target><placeholder/></target><source><mobile>On the move</mobile></source></doc>");
+                     "<doc><target><placeholder></placeholder></target><source><mobile>On the move</mobile></source></doc>");
 
         mobile.moveToBottom(target);
 
         assertEquals(d.toString(),
-                     "<doc><target><placeholder/><mobile>On the move</mobile></target><source/></doc>");
+                     "<doc><target><placeholder></placeholder><mobile>On the move</mobile></target><source></source></doc>");
     }
 
     @Test
@@ -574,12 +574,12 @@
         mobile.text("On the move");
 
         assertEquals(d.toString(),
-                     "<doc><before/><source><mobile>On the move</mobile><grok/></source><after/></doc>");
+                     "<doc><before></before><source><mobile>On the move</mobile><grok></grok></source><after></after></doc>");
 
         source.removeChildren();
 
         assertEquals(d.toString(),
-                     "<doc><before/><source/><after/></doc>");
+                     "<doc><before></before><source></source><after></after></doc>");
     }
 
     @Test
@@ -594,12 +594,12 @@
         source.element("grok");
 
         assertEquals(d.toString(),
-                     "<doc><source><mobile>On the move</mobile><grok/></source></doc>");
+                     "<doc><source><mobile>On the move</mobile><grok></grok></source></doc>");
 
         source.pop();
 
         assertEquals(d.toString(),
-                     "<doc><mobile>On the move</mobile><grok/></doc>");
+                     "<doc><mobile>On the move</mobile><grok></grok></doc>");
     }
 
     @Test
@@ -640,11 +640,28 @@
         Node text = mobile.text("On the move");
 
         assertEquals(d.toString(),
-                     "<doc><target><placeholder/></target><source><mobile>On the move</mobile></source></doc>");
+                     "<doc><target><placeholder></placeholder></target><source><mobile>On the move</mobile></source></doc>");
 
         text.wrap("em", "class", "bold");
 
         assertEquals(d.toString(),
-                     "<doc><target><placeholder/></target><source><mobile><em class=\"bold\">On the move</em></mobile></source></doc>");
+                     "<doc><target><placeholder></placeholder></target><source><mobile><em class=\"bold\">On the move</em></mobile></source></doc>");
+    }
+
+    /**
+     * TAP5-385
+     */
+    @Test
+    public void empty_html_elements()
+    {
+        Document d = new Document();
+
+        Element root = d.newRootElement("doc");
+
+        root.element("hr");
+        root.element("br");
+        root.element("img");
+
+        assertEquals(d.toString(), "<doc><hr/><br/><img/></doc>");
     }
 }

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/MarkupWriterImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/MarkupWriterImplTest.java?rev=720686&r1=720685&r2=720686&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/MarkupWriterImplTest.java (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/MarkupWriterImplTest.java Tue Nov 25 16:47:21 2008
@@ -154,7 +154,7 @@
 
         w.attributes("foo", "bar", "gnip", "gnop");
 
-        assertEquals(w.toString(), "<root foo=\"bar\" gnip=\"gnop\"/>");
+        assertEquals(w.toString(), "<root foo=\"bar\" gnip=\"gnop\"></root>");
     }
 
     @Test
@@ -204,7 +204,7 @@
         w.write(null);
         w.end();
 
-        assertEquals(w.toString(), "<root/>");
+        assertEquals(w.toString(), "<root></root>");
     }
 
     @Test

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/dom/document_with_root_element_and_attributes.txt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/dom/document_with_root_element_and_attributes.txt?rev=720686&r1=720685&r2=720686&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/dom/document_with_root_element_and_attributes.txt (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/dom/document_with_root_element_and_attributes.txt Tue Nov 25 16:47:21 2008
@@ -1 +1 @@
-<has-attributes barney="rubble" fred="flintstone"/>
\ No newline at end of file
+<has-attributes barney="rubble" fred="flintstone"></has-attributes>
\ No newline at end of file

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/dom/nested_elements.txt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/dom/nested_elements.txt?rev=720686&r1=720685&r2=720686&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/dom/nested_elements.txt (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/dom/nested_elements.txt Tue Nov 25 16:47:21 2008
@@ -1 +1 @@
-<population><person first-name="Fred" last-name="Flintstone"/><person first-name="Barney" last-name="Rubble"/></population>
\ No newline at end of file
+<population><person first-name="Fred" last-name="Flintstone"></person><person first-name="Barney" last-name="Rubble"></person></population>
\ No newline at end of file