gawel / pyquery

A jquery-like library for python
http://pyquery.rtfd.org/
Other
2.3k stars 182 forks source link

remove() no longer adds a space #220

Closed jcushman closed 3 years ago

jcushman commented 3 years ago

In PyQuery, remove() currently adds a space in place of the removed element:

>>> print(PyQuery('<a>1<b>2</b>3</a>').remove('b'))
<a>1 3</a>

The same line in jQuery would print <a>12</a>.

I think jQuery's behavior is correct here, because the new space will sometimes change the semantics of the document. And it's possible to manually add a space after the target element before removing it, if you want a space, but not possible to manually remove the space if you don't want it.

So, this PR removes the extra space from remove().

gawel commented 3 years ago

Can you add an entry to the changelog ? Thanks

jcushman commented 3 years ago

Changelog updated.