pyquery
pyquery copied to clipboard
hierarchy selectors not working for 'not_'
elijahr created an issue 2009-12-20
html = """<html>
<body>
<ul>
<li>C</li>
<li>D</li>
</ul>
<div>
<ul>
<li>E</li>
<li>F</li>
</ul>
</div>
</body>
</html>"""
import pyquery
q = pyquery.PyQuery(html)
ul = q.find('ul').not_('div > ul')
print ul
#<ul><li>C</li><li>D</li></ul><ul><li>E</li><li>F</li></ul>
# should be printing:
# <ul><li>C</li><li>D</li></ul>
Comments:
elijahr
print ul.eq(1).is_('div > ul')
# False
# should print:
# True
The scope of this bug is larger than the not_ method; the selected elements' context is lost, so that any further filtering on a PyQuery object cannot be done using selectors that reference parent elements. 2009-12-20