Mercurial > libervia-web
comparison src/browser/sat_browser/nativedom.py @ 488:747eaa662353
browser side (nativedom): new properties managed: TEXT_NODE, ELEMENT_NODE, ATTRIBUTE_NODE, COMMENT_NODE, nodeType
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 24 Jun 2014 00:42:45 +0200 |
parents | 97c72fe4a5f2 |
children | a5019e62c3e9 |
comparison
equal
deleted
inserted
replaced
487:e588335b6aa8 | 488:747eaa662353 |
---|---|
23 """ | 23 """ |
24 | 24 |
25 from __pyjamas__ import JS | 25 from __pyjamas__ import JS |
26 | 26 |
27 | 27 |
28 class Node(): | 28 class Node(object): |
29 | 29 |
30 def __init__(self, js_node): | 30 def __init__(self, js_node): |
31 self._node = js_node | 31 self._node = js_node |
32 | 32 |
33 def _jsNodesList2List(self, js_nodes_list): | 33 def _jsNodesList2List(self, js_nodes_list): |
35 for i in range(len(js_nodes_list)): | 35 for i in range(len(js_nodes_list)): |
36 #ret.append(Element(js_nodes_list.item(i))) | 36 #ret.append(Element(js_nodes_list.item(i))) |
37 ret.append(self.__class__(js_nodes_list.item(i))) # XXX: Ugly, but used to word around a Pyjamas's bug | 37 ret.append(self.__class__(js_nodes_list.item(i))) # XXX: Ugly, but used to word around a Pyjamas's bug |
38 return ret | 38 return ret |
39 | 39 |
40 @property | 40 def __getattr__(self, name): |
41 def nodeName(self): | 41 if name in ('TEXT_NODE', 'ELEMENT_NODE', 'ATTRIBUTE_NODE', 'COMMENT_NODE', 'nodeName', 'nodeType', 'wholeText'): |
42 return self._node.nodeName | 42 return getattr(self._node, name) |
43 | 43 return object.__getattribute__(self, name) |
44 @property | |
45 def wholeText(self): | |
46 return self._node.wholeText | |
47 | 44 |
48 @property | 45 @property |
49 def childNodes(self): | 46 def childNodes(self): |
50 return self._jsNodesList2List(self._node.childNodes) | 47 return self._jsNodesList2List(self._node.childNodes) |
51 | 48 |