_base.py 文件源码

python
阅读 31 收藏 0 点赞 0 评论 0

项目:v2ex-tornado-2 作者: coderyy 项目源码 文件源码
def elementInScope(self, target, variant=None):

        #If we pass a node in we match that. if we pass a string
        #match any node with that name
        exactNode = hasattr(target, "nameTuple")

        listElementsMap = {
            None:(scopingElements, False),
            "button":(scopingElements | set([(namespaces["html"], "button")]), False),
            "list":(scopingElements | set([(namespaces["html"], "ol"),
                                           (namespaces["html"], "ul")]), False),
            "table":(set([(namespaces["html"], "html"),
                          (namespaces["html"], "table")]), False),
            "select":(set([(namespaces["html"], "optgroup"), 
                           (namespaces["html"], "option")]), True)
            }
        listElements, invert = listElementsMap[variant]

        for node in reversed(self.openElements):
            if (node.name == target and not exactNode or
                node == target and exactNode):
                return True
            elif (invert ^ (node.nameTuple in listElements)):                
                return False

        assert False # We should never reach this point
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号