changeset 245:43881c3dda9d

browser side: added Node.setAttribute and Node.toxml to nativedom
author Goffi <goffi@goffi.org>
date Sat, 09 Nov 2013 10:23:33 +0100
parents 43a27ffc74df
children d7c41c84d062
files browser_side/nativedom.py
diffstat 1 files changed, 12 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/browser_side/nativedom.py	Fri Nov 08 16:34:54 2013 +0100
+++ b/browser_side/nativedom.py	Sat Nov 09 10:23:33 2013 +0100
@@ -28,7 +28,7 @@
 
 
 class Node():
-   
+
     def __init__(self, js_node):
         self._node = js_node
 
@@ -50,9 +50,15 @@
     def getAttribute(self, attr):
         return self._node.getAttribute(attr)
 
+    def setAttribute(self, attr, value):
+        return self._node.setAttribute(attr, value)
+
     def hasAttribute(self, attr):
         return self._node.hasAttribute(attr)
 
+    def toxml(self):
+        return JS("""this._node.outerHTML || new XMLSerializer().serializeToString(this._node);""")
+
 
 class Element(Node):
 
@@ -61,9 +67,10 @@
 
     def getElementsByTagName(self, tagName):
         return self._jsNodesList2List(self._node.getElementsByTagName(tagName))
-   
+
+
 class Document(Node):
-    
+
     def __init__(self, js_document):
         Node.__init__(self, js_document)
 
@@ -71,8 +78,9 @@
     def documentElement(self):
         return Element(self._node.documentElement)
 
+
 class NativeDOM:
-    
+
     def __init__(self):
         JS("""