Manipulate document fragments rather than HTML strings

#changelog