PyQuery .children() method wrong behavior #8

gawel opened this Issue Nov 28, 2012 · 3 comments

2 participants

html = """ <div> <a href="#">text1<img src="abc"/>text2</a> <a href="#">text3<img src="xyz"/>text4</a> </div> """

tree = pq(html)

for a in tree('a'): a = pq(a) print a.children()


    <img src="abc"/>text2
    <img src="xyz"/>text4

Instead of:

    text1<img src="abc"/>text2
    text3<img src="xyz"/>text4

I think it's weird to return with text1 prepend. Since the text1 is the text of previous tag, in this case <a>.


if we print text2 we should print text1 too :) I think this is a real issue


I think we can discuss about this. Since children() will return a pyquery object, and a prepend text is not proper in a pyquery object.
For example if I try:

>>> test = """textbefore<div>text</div>"""
>>> t = PyQuery(test)
>>> print(t)

But if children() return a object like this, it's not like what children() should do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment