tapestry-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From hls...@apache.org
Subject svn commit: r941087 - in /tapestry/tapestry5/trunk/tapestry-core/src: main/resources/org/apache/tapestry5/tapestry.js test/app1/LinkSubmitDemo.tml
Date Tue, 04 May 2010 23:09:25 GMT
Author: hlship
Date: Tue May  4 23:09:25 2010
New Revision: 941087

URL: http://svn.apache.org/viewvc?rev=941087&view=rev
Log:
TAP5-1129: LinkSubmit should render minimally (and as <span> tag) and then fill in the
details on the client

Modified:
    tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
    tapestry/tapestry5/trunk/tapestry-core/src/test/app1/LinkSubmitDemo.tml

Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js?rev=941087&r1=941086&r2=941087&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
(original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/tapestry.js
Tue May  4 23:09:25 2010
@@ -554,32 +554,30 @@ var Tapestry = {
 			Tapestry.ScriptManager.virtualScripts.push(complete);
 		});
 	},
-	
-	/** 
-	 * Creates a clone of the indicated element, but with the alternate tag name.
-	 * Attributes of the original node are copied to the new node. Tag names should
-	 * be all upper-case. The content of the original element is copied to the new element
-	 * and the original element is removed. Event observers on the original element will
-	 * be lost.
-	 * 
-	 * @param element element or element id
-	 * @return the new element
-	 *  @since 5.2.0
-	 */
-	replaceElementTagName : function(element, newTagName)
-	{
-		var newElement = new Element(newTagName);
-		
-		$A($(element).attributes).each(function (attribute) {
-			newElement.writeAttribute(attribute.name, attribute.value);
-		});
-		
-		/** Copy the original element's content over. */
-		newElement.update($(element).innerHTML);
-		
-		$(element).insert({ before: newElement}).remove();
-		
-		return newElement;
+
+	/**
+	 * Creates a clone of the indicated element, but with the alternate tag
+	 * name. Attributes of the original node are copied to the new node. Tag
+	 * names should be all upper-case. The content of the original element is
+	 * copied to the new element and the original element is removed. Event
+	 * observers on the original element will be lost.
+	 * 
+	 * @param element
+	 *            element or element id
+	 * @since 5.2.0
+	 */
+	replaceElementTagName : function(element, newTagName) {
+
+		var tag = $(element).tagName;
+		var outerHTML = $(element).outerHTML;
+
+		var replaceHTML = outerHTML.replace(new RegExp("^<" + tag, "i"),
+				"<" + newTagName).replace(new RegExp("</" + tag + ">$", "i"),
+				"</" + newTagName + ">");
+
+		$(element).insert( {
+			before : replaceHTML
+		}).remove();
 	}
 };
 
@@ -1996,8 +1994,8 @@ Tapestry.ScriptManager = {
  * are not prefixed in any way, valueing readability over preventing naming
  * conflicts.
  * <p>
- * However, this technique is being phased out and will soon be deprecated
- * as it is all too easy to cause memory cycles and leaks (especially in IE).
+ * However, this technique is being phased out and will soon be deprecated as it
+ * is all too easy to cause memory cycles and leaks (especially in IE).
  * 
  * @param element
  *            an element instance or element id

Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/app1/LinkSubmitDemo.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/app1/LinkSubmitDemo.tml?rev=941087&r1=941086&r2=941087&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/app1/LinkSubmitDemo.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/app1/LinkSubmitDemo.tml Tue May  4 23:09:25
2010
@@ -1,23 +1,25 @@
 <html t:type="border" xmlns:t="http://tapestry.apache.org/schema/tapestry_5_0_0.xsd">
-    <h1>Link Submit Demo</h1>
-    
-    <p>Result: ${result}.</p>
-
-    <t:form>
-        <t:errors/>
-
-        <t:textfield t:id="name"/>
-        <br/>
-        <t:linksubmit t:id="fred" context="formContext" alt="f">Fred</t:linksubmit>
-        <t:linksubmit t:id="barney" defer="true" event="neighbor" alt="b">Barney</t:linksubmit>
-
-    </t:form>
-
-    <dl>
-        <dt>Name</dt>
-        <dd id="name-value">${name}</dd>
-        <dt>Last Clicked</dt>
-        <dd id="last-clicked">${lastClicked}</dd>
-    </dl>
+  <h1>Link Submit Demo</h1>
+
+  <p>Result: ${result}.</p>
+
+  <t:form>
+    <t:errors/>
+
+    <t:textfield t:id="name"/>
+    <br/>
+    <t:linksubmit t:id="fred" context="formContext" alt="f">
+      <span class="nested">Fred</span>
+    </t:linksubmit>
+    <t:linksubmit t:id="barney" defer="true" event="neighbor" alt="b">Barney</t:linksubmit>
+
+  </t:form>
+
+  <dl>
+    <dt>Name</dt>
+    <dd id="name-value">${name}</dd>
+    <dt>Last Clicked</dt>
+    <dd id="last-clicked">${lastClicked}</dd>
+  </dl>
 
 </html>
\ No newline at end of file



Mime
View raw message