[pypy-svn] r39343 - pypy/dist/pypy/translator/js/examples/console

fijal at codespeak.net fijal at codespeak.net
Fri Feb 23 16:37:27 CET 2007


Author: fijal
Date: Fri Feb 23 16:37:25 2007
New Revision: 39343

Modified:
   pypy/dist/pypy/translator/js/examples/console/client.py
Log:
Use less innerHTML, saves some escaping troubles


Modified: pypy/dist/pypy/translator/js/examples/console/client.py
==============================================================================
--- pypy/dist/pypy/translator/js/examples/console/client.py	(original)
+++ pypy/dist/pypy/translator/js/examples/console/client.py	Fri Feb 23 16:37:25 2007
@@ -9,7 +9,14 @@
 glob = Glob()
 
 def add_text(txt):
-    dom.document.getElementById("data").innerHTML += txt    
+    data_elem = dom.document.getElementById("data")
+    if data_elem.childNodes:
+        data = data_elem.childNodes[0].nodeValue + txt
+    else:
+        data = txt
+    while data_elem.childNodes:
+        data_elem.removeChild(data_elem.childNodes[0])
+    data_elem.appendChild(dom.document.createTextNode(data))
 
 def refresh_console(msg):
     inp_elem = dom.document.getElementById("inp")



More information about the Pypy-commit mailing list