本文整理汇总了Python中pyjamas.DOM.walkChildren方法的典型用法代码示例。如果您正苦于以下问题:Python DOM.walkChildren方法的具体用法?Python DOM.walkChildren怎么用?Python DOM.walkChildren使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyjamas.DOM
的用法示例。
在下文中一共展示了DOM.walkChildren方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: onCompletion
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import walkChildren [as 别名]
def onCompletion(self, responseText):
# TODO - cope with unicode / utf-8 test results
print "onCompletion", self.unittest.tests_outstanding, self.test_name
self.unittest.async_test_name = self.test_name
e1 = DOM.getElementById('testcompare1')
e2 = DOM.getElementById('testcompare2')
e1.innerHTML = responseText
e2.innerHTML = responseText
i1 = DOM.walkChildren(e1)
i2 = DOM.walkChildren(e2)
ok = True
while ok:
try:
ec1 = i1.next()
ec2 = i2.next()
except StopIteration:
break
ok = ok and (ec1.nodeType == ec2.nodeType)
if not ok:
break
print ec1.nodeName, ec1.nodeValue
ok = ok and (ec1.nodeName == ec2.nodeName)
ok = ok and (ec1.nodeValue == ec2.nodeValue)
if not ok:
break
if hasattr(ec1, 'getInnerText') and hasattr(ec2, 'getInnerText'):
print ec1.getInnerText()
ok = ok and (ec1.getInnerText() == ec2.getInnerText())
if not ok:
break
if hasattr(ec1, 'attributes') and hasattr(ec2, 'attributes'):
a1 = ec1.attributes
a2 = ec2.attributes
ok = hasattr(a1, 'length') and hasattr(a2, 'length')
if not ok:
break
ok = ok and (a1.length == a2.length)
if not ok:
break
for i in range(a1.length):
ai1 = a1.item(i)
ai2 = a2.item(i)
ok = ok and (ai1.nodeValue == ai2.nodeValue)
ok = ok and (ai1.nodeName == ai2.nodeName)
self.unittest.assertTrue(ok)
self.unittest.tests_outstanding -= 1
# clear the test HTML
e1.innerHTML = ''
e2.innerHTML = ''
示例2: getElementsByTagName
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import walkChildren [as 别名]
def getElementsByTagName(element, tagname):
res = []
el = _check_tagname(element, tagname)
if el:
res.append(el)
it = DOM.walkChildren(element)
while True:
try:
child = it.next()
except StopIteration:
break
el = _check_tagname(child, tagname)
if el:
res.append(el)
return res
示例3: setTemplateText
# 需要导入模块: from pyjamas import DOM [as 别名]
# 或者: from pyjamas.DOM import walkChildren [as 别名]
def setTemplateText(self, text):
"""
Set the template text; if the template is not HTML, a subclass
could override this to pre-process the text into HTML before
passing it to the default implementation.
"""
if self.allowEdit:
self.originalText = text
# If we have children, remove them all first since we are
# trashing their DOM
for child in List(self.children):
self.remove(child)
DOM.setInnerHTML(self.getElement(), text)
self.elementsById = {}
self.links = []
self.metaTags = {}
self.forms = []
self.metaTagList = []
# Make the ids unique and store a pointer to each named element
for node in DOM.walkChildren(self.getElement()):
#console.log("Passing node with name %s", node.nodeName)
if node.nodeName == "META":
name = node.getAttribute("name")
content = node.getAttribute("content")
console.log("Found meta %o name %s content %s",
node, name, content)
self.metaTags[name] = content
self.metaTagList.append(node)
elif node.nodeName == "BODY":
self.body = node
elif node.nodeName == "TITLE":
self.title = DOM.getInnerText(node)
elif node.nodeName == "FORM":
self.forms.append(node)
nodeId = DOM.getAttribute(node, "id")
if nodeId:
self.elementsById[nodeId] = node
DOM.setAttribute(node, "id", self.id + ":" + node.id)
nodeHref = DOM.getAttribute(node, "href")
if nodeHref:
self.links.append(node)
self.loaded = True
if self.attached:
self.attachWidgets()
self.widgetsAttached = True
if self.allowEdit:
self.editor = None
self.editButton = Label("edit "+unescape(self.templateName))
self.editButton.addStyleName("link")
self.editButton.addStyleName("ContentPanelEditLink")
self.editButton.addClickListener(EventDelegate("onClick", self,
self.onEditContentClick))
ComplexPanel.insert(self, self.editButton, self.getElement(),
len(self.children))
self.notifyLoadListeners()