Skip to content

Lint fixes #222

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Jan 12, 2016
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Don't let the lxml treewalker walk above the fragment root
  • Loading branch information
gsnedders committed Jan 12, 2016
commit 270a2ca14fafc989f8f1bd4f79db2f4bd9f4d1fc
4 changes: 4 additions & 0 deletions html5lib/treewalkers/lxmletree.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,10 @@ def __len__(self):
class TreeWalker(_base.NonRecursiveTreeWalker):
def __init__(self, tree):
if hasattr(tree, "getroot"):
self.fragmentChildren = set()
tree = Root(tree)
elif isinstance(tree, list):
self.fragmentChildren = set(tree)
tree = FragmentRoot(tree)
_base.NonRecursiveTreeWalker.__init__(self, tree)
self.filter = ihatexml.InfosetFilter()
Expand Down Expand Up @@ -197,5 +199,7 @@ def getParentNode(self, node):
if key == "text":
return node
# else: fallback to "normal" processing
elif node in self.fragmentChildren:
return None

return node.getparent()