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/12/04 18:43:04 UTC
svn commit: r723381 - in /tapestry/tapestry5/branches/5.0: ./
src/site/apt/guide/ tapestry-core/src/main/java/org/apache/tapestry5/dom/
tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/
tapestry-core/src/test/java/org/apache/tapestry...
Author: hlship
Date: Thu Dec 4 09:43:04 2008
New Revision: 723381
URL: http://svn.apache.org/viewvc?rev=723381&view=rev
Log:
TAP5-401: When rendering HTML content (not XML) Tapestry should always render open and close tags for most elements, even if the content is empty
Modified:
tapestry/tapestry5/branches/5.0/src/site/apt/guide/content-type.apt
tapestry/tapestry5/branches/5.0/tapestry-core/src/main/java/org/apache/tapestry5/dom/DefaultMarkupModel.java
tapestry/tapestry5/branches/5.0/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/OutputTest.java
tapestry/tapestry5/branches/5.0/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java
tapestry/tapestry5/branches/5.0/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/MarkupWriterImplTest.java
tapestry/tapestry5/branches/5.0/tapestry-core/src/test/resources/org/apache/tapestry5/dom/document_with_root_element_and_attributes.txt
tapestry/tapestry5/branches/5.0/tapestry-core/src/test/resources/org/apache/tapestry5/dom/nested_elements.txt
tapestry/tapestry5/branches/5.0/tapestry-project.ipr
Modified: tapestry/tapestry5/branches/5.0/src/site/apt/guide/content-type.apt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.0/src/site/apt/guide/content-type.apt?rev=723381&r1=723380&r2=723381&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.0/src/site/apt/guide/content-type.apt (original)
+++ tapestry/tapestry5/branches/5.0/src/site/apt/guide/content-type.apt Thu Dec 4 09:43:04 2008
@@ -8,19 +8,15 @@
* 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
+ * hr
- * p
-
- * textarea
-
- * select
+ * img
[]
@@ -41,9 +37,8 @@
Input/Output Character Set
The character set (aka character encoding) used when writing output and when parsing requests is normally "utf-8".
- All pages use the same encoding, which can be set using the
+ All pages use the same encoding, which can be set using the
<<<tapestry.charset>>>
{{{conf.html}configuration setting}}.
-
-
\ No newline at end of file
+
Modified: tapestry/tapestry5/branches/5.0/tapestry-core/src/main/java/org/apache/tapestry5/dom/DefaultMarkupModel.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.0/tapestry-core/src/main/java/org/apache/tapestry5/dom/DefaultMarkupModel.java?rev=723381&r1=723380&r2=723381&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.0/tapestry-core/src/main/java/org/apache/tapestry5/dom/DefaultMarkupModel.java (original)
+++ tapestry/tapestry5/branches/5.0/tapestry-core/src/main/java/org/apache/tapestry5/dom/DefaultMarkupModel.java Thu Dec 4 09:43:04 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/>").
*/
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/branches/5.0/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/OutputTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.0/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/OutputTest.java?rev=723381&r1=723380&r2=723381&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.0/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/OutputTest.java (original)
+++ tapestry/tapestry5/branches/5.0/tapestry-core/src/test/java/org/apache/tapestry5/corelib/components/OutputTest.java Thu Dec 4 09:43:04 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/branches/5.0/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.0/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java?rev=723381&r1=723380&r2=723381&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.0/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java (original)
+++ tapestry/tapestry5/branches/5.0/tapestry-core/src/test/java/org/apache/tapestry5/dom/DOMTest.java Thu Dec 4 09:43:04 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-401
+ */
+ @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/branches/5.0/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/MarkupWriterImplTest.java
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.0/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/MarkupWriterImplTest.java?rev=723381&r1=723380&r2=723381&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.0/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/MarkupWriterImplTest.java (original)
+++ tapestry/tapestry5/branches/5.0/tapestry-core/src/test/java/org/apache/tapestry5/internal/services/MarkupWriterImplTest.java Thu Dec 4 09:43:04 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/branches/5.0/tapestry-core/src/test/resources/org/apache/tapestry5/dom/document_with_root_element_and_attributes.txt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.0/tapestry-core/src/test/resources/org/apache/tapestry5/dom/document_with_root_element_and_attributes.txt?rev=723381&r1=723380&r2=723381&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.0/tapestry-core/src/test/resources/org/apache/tapestry5/dom/document_with_root_element_and_attributes.txt (original)
+++ tapestry/tapestry5/branches/5.0/tapestry-core/src/test/resources/org/apache/tapestry5/dom/document_with_root_element_and_attributes.txt Thu Dec 4 09:43:04 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/branches/5.0/tapestry-core/src/test/resources/org/apache/tapestry5/dom/nested_elements.txt
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.0/tapestry-core/src/test/resources/org/apache/tapestry5/dom/nested_elements.txt?rev=723381&r1=723380&r2=723381&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.0/tapestry-core/src/test/resources/org/apache/tapestry5/dom/nested_elements.txt (original)
+++ tapestry/tapestry5/branches/5.0/tapestry-core/src/test/resources/org/apache/tapestry5/dom/nested_elements.txt Thu Dec 4 09:43:04 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
Modified: tapestry/tapestry5/branches/5.0/tapestry-project.ipr
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/branches/5.0/tapestry-project.ipr?rev=723381&r1=723380&r2=723381&view=diff
==============================================================================
--- tapestry/tapestry5/branches/5.0/tapestry-project.ipr (original)
+++ tapestry/tapestry5/branches/5.0/tapestry-project.ipr Thu Dec 4 09:43:04 2008
@@ -452,6 +452,36 @@
<entry key="$PROJECT_DIR$">
<value>
<SvnBranchConfiguration>
+ <option name="branchMap">
+ <map>
+ <entry key="https://svn.apache.org/repos/asf/tapestry/tapestry5/branches">
+ <value>
+ <list>
+ <SvnBranchItem>
+ <option name="creationDateMillis" value="1228328601230" />
+ <option name="revision" value="722998" />
+ <option name="url" value="https://svn.apache.org/repos/asf/tapestry/tapestry5/branches/5.0" />
+ </SvnBranchItem>
+ <SvnBranchItem>
+ <option name="creationDateMillis" value="1221736060801" />
+ <option name="revision" value="696628" />
+ <option name="url" value="https://svn.apache.org/repos/asf/tapestry/tapestry5/branches/5.1-dev" />
+ </SvnBranchItem>
+ <SvnBranchItem>
+ <option name="creationDateMillis" value="1211309495890" />
+ <option name="revision" value="658390" />
+ <option name="url" value="https://svn.apache.org/repos/asf/tapestry/tapestry5/branches/hlship-20080520" />
+ </SvnBranchItem>
+ <SvnBranchItem>
+ <option name="creationDateMillis" value="1178591494728" />
+ <option name="revision" value="536042" />
+ <option name="url" value="https://svn.apache.org/repos/asf/tapestry/tapestry5/branches/hlship-20070503" />
+ </SvnBranchItem>
+ </list>
+ </value>
+ </entry>
+ </map>
+ </option>
<option name="branchUrls">
<list>
<option value="https://svn.apache.org/repos/asf/tapestry/tapestry5/branches" />