tapestry-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From andy...@apache.org
Subject svn commit: r547520 - in /tapestry/tapestry4/trunk/tapestry-framework/src/js: tapestry/core.js tests/test_html.js
Date Fri, 15 Jun 2007 04:19:35 GMT
Author: andyhot
Date: Thu Jun 14 21:19:34 2007
New Revision: 547520

URL: http://svn.apache.org/viewvc?view=rev&rev=547520
Log:
more regexp fixes and (real-world) test. Input tags aren't expanded but most importantly we
stop at the first closing tag - otherwise the matcher gets wicked...

Modified:
    tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js
    tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_html.js

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js?view=diff&rev=547520&r1=547519&r2=547520
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tapestry/core.js Thu Jun 14 21:19:34
2007
@@ -446,7 +446,7 @@
  */
 tapestry.html={
 
-    CompactElementRegexp:new RegExp('<([a-zA-Z]*)(.*?)/>'), // regexp for compact html
elements
+    CompactElementRegexp:/<([a-zA-Z](?!nput)[a-zA-Z]*)([^>]*?)\/>/g, // regexp for
compact html elements
     CompactElementReplacer:'<$1$2></$1>', // replace pattern for compact html
elements
 	
     /**
@@ -557,10 +557,7 @@
 
 	_processCompactElements:function(htmlData)
  	{
-            while (htmlData.match(this.CompactElementRegexp)){                
-                htmlData = htmlData.replace(this.CompactElementRegexp, this.CompactElementReplacer);
-        }
-        return htmlData;
+            return htmlData.replace(this.CompactElementRegexp, this.CompactElementReplacer);
       
  	}
 }
 

Modified: tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_html.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_html.js?view=diff&rev=547520&r1=547519&r2=547520
==============================================================================
--- tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_html.js (original)
+++ tapestry/tapestry4/trunk/tapestry-framework/src/js/tests/test_html.js Thu Jun 14 21:19:34
2007
@@ -32,8 +32,37 @@
 }
 
 function test_html_processTextareas(){
-    var initial = "start<textarea id='2' rows=4/>";
-    var expected = "start<textarea id='2' rows=4></textarea>";
+    var initial = "start<textarea id='2' rows=4/>22<input type='text'/><textarea/><div
id=1/>";
+    var expected = "start<textarea id='2' rows=4></textarea>22<input type='text'/><textarea></textarea><div
id=1></div>";
+    
+    jum.assertEquals(expected, tapestry.html._processCompactElements(initial));
+    jum.assertEquals(expected + expected, 
+        tapestry.html._processCompactElements(initial+initial));
+}
+
+function test_html_processResponse(){
+    var initial = '<div id="editTopic"><form method="post" action="Topics,topicList.$Form.sdirect"
id="Form"> '
+        +'<div style="display:none;" id="Formhidden"><input type="hidden" name="formids"
value="topicName,shortDescriptiveText,descriptiveText,If,If_0,updateTopic" /> '
+        +'<input type="hidden" name="updateParts" value="list" /> <input type="hidden"
name="updateParts" value="edit" /> <input type="hidden" name="reservedids" '
+        +'value="updateParts" /> <input type="hidden" name="submitmode" value="" />
<input type="hidden" name="submitname" value="" /> <input type="hidden" name="If"
value="T" /> '
+        +'<input type="hidden" name="If_0" value="F" /> </div> Make the desired
changes to this topic. <fieldset> <div> <label for="topicName" class="required">Topic
Name</label> '
+        +'<input type="text" name="name" value="Uncategorized" id="tName" /> </div>
<div> <label for="shortDescriptiveText" class="required">Short Description</label>
'
+        +'<textarea name="shortDescriptiveText" id="shortDescriptiveText" cols="40" rows="4">Information</textarea>
</div> <div> <label for="descriptiveText">Additional '
+        +'Description</label> <textarea name="descriptiveText" id="descriptiveText"
cols="40" rows="4"/> </div> <div> <label for="pUrlField" class="required">Home
'
+        +'Url</label> <input type="text" name="pUrlField" value="ba.org" id="pUrlField"
size="40" /> Verified </div> <div></div> </fieldset> <div>
'
+        +'<input type="submit" name="uTopic" id="uTopic" value="Save Changes"/> <!--input
type="submit" jwcid="cancelTopic@Submit" '
+        +'listener="listener:doCancel" value="message:label.cancel-changes" async="true"/--></div>
</form> </div>';
+    var expected = '<div id="editTopic"><form method="post" action="Topics,topicList.$Form.sdirect"
id="Form"> '
+        +'<div style="display:none;" id="Formhidden"><input type="hidden" name="formids"
value="topicName,shortDescriptiveText,descriptiveText,If,If_0,updateTopic" /> '
+        +'<input type="hidden" name="updateParts" value="list" /> <input type="hidden"
name="updateParts" value="edit" /> <input type="hidden" name="reservedids" '
+        +'value="updateParts" /> <input type="hidden" name="submitmode" value="" />
<input type="hidden" name="submitname" value="" /> <input type="hidden" name="If"
value="T" /> '
+        +'<input type="hidden" name="If_0" value="F" /> </div> Make the desired
changes to this topic. <fieldset> <div> <label for="topicName" class="required">Topic
Name</label> '
+        +'<input type="text" name="name" value="Uncategorized" id="tName" /> </div>
<div> <label for="shortDescriptiveText" class="required">Short Description</label>
'
+        +'<textarea name="shortDescriptiveText" id="shortDescriptiveText" cols="40" rows="4">Information</textarea>
</div> <div> <label for="descriptiveText">Additional '
+        +'Description</label> <textarea name="descriptiveText" id="descriptiveText"
cols="40" rows="4"></textarea> </div> <div> <label for="pUrlField"
class="required">Home '
+        +'Url</label> <input type="text" name="pUrlField" value="ba.org" id="pUrlField"
size="40" /> Verified </div> <div></div> </fieldset> <div>
'
+        +'<input type="submit" name="uTopic" id="uTopic" value="Save Changes"/> <!--input
type="submit" jwcid="cancelTopic@Submit" '
+        +'listener="listener:doCancel" value="message:label.cancel-changes" async="true"/--></div>
</form> </div>';
     
     jum.assertEquals(expected, tapestry.html._processCompactElements(initial));
     jum.assertEquals(expected + expected, 



Mime
View raw message