[pypy-svn] r35027 - in pypy/dist/pypy/translator/js/modules: . test
guido at codespeak.net
guido at codespeak.net
Mon Nov 27 14:08:21 CET 2006
Author: guido
Date: Mon Nov 27 14:08:19 2006
New Revision: 35027
Modified:
pypy/dist/pypy/translator/js/modules/dom.py
pypy/dist/pypy/translator/js/modules/test/test_dom.py
Log:
Added missing __setattr__ on Node... :|
Modified: pypy/dist/pypy/translator/js/modules/dom.py
==============================================================================
--- pypy/dist/pypy/translator/js/modules/dom.py (original)
+++ pypy/dist/pypy/translator/js/modules/dom.py Mon Nov 27 14:08:19 2006
@@ -65,6 +65,7 @@
class Node(EventTarget):
"""base class of all node types"""
+ _original = None
def __init__(self, node=None):
self._original = node
@@ -84,6 +85,14 @@
value = getattr(self._original, name)
return _wrap(value)
+ def __setattr__(self, name, value):
+ """set an attribute on the wrapped node"""
+ if name in dir(self):
+ return super(Node, self).__setattr__(name, value)
+ if name not in self._fields:
+ raise NameError, name
+ setattr(self._original, name, value)
+
def __eq__(self, other):
original = getattr(other, '_original', other)
return original is self._original
Modified: pypy/dist/pypy/translator/js/modules/test/test_dom.py
==============================================================================
--- pypy/dist/pypy/translator/js/modules/test/test_dom.py (original)
+++ pypy/dist/pypy/translator/js/modules/test/test_dom.py Mon Nov 27 14:08:19 2006
@@ -71,6 +71,18 @@
assert div.nodeType == 1
assert document.documentElement.childNodes[-1]._original is div._original
+def code_nodeValue():
+ window = get_window()
+ document = window.document
+ td = document.createElement('td')
+ td.appendChild(document.createTextNode('foo'))
+ td.childNodes[0].nodeValue = 'bar'
+ return td.childNodes[0].nodeValue
+
+def test_nodeValue():
+ nodevalue = code_nodeValue()
+ assert nodevalue == 'bar'
+
def code_node_eq():
window = get_window()
body = window.document.getElementsByTagName('body')[0]
More information about the Pypy-commit
mailing list