You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Cloned elements don't have an owner Document, which makes me unable to set output settings for these elements, and that leads to some issues in my app. Try this:
public class Main {
public static void main(String[] args) {
Document doc = Jsoup.parse("<div></div>");
doc.outputSettings(new Document.OutputSettings().prettyPrint(false));
Element e = doc.body();
Element copy = e.clone();
System.out.println(e.outerHtml());//returns html not pretty printed
System.out.println(copy.outerHtml());//returns html pretty printed
System.out.println(copy.ownerDocument());//returns null
}
}
Of course, here it doesn't seem important, but what if you have 2 div with "display:inline-block" side by side ? The pretty printed html would render with an extra space between the 2 divs which is not the expected behaviour.
Shouldn't the outputSettings being copied to the cloned element ? Or the owner document being cloned as well as the cloned element ? Or at least, shouldn't we be provided a function to set outputSetting directly to an Element ? The owner document could be generated at that moment if needed ?
The text was updated successfully, but these errors were encountered:
Cloned elements don't have an owner Document, which makes me unable to set output settings for these elements, and that leads to some issues in my app. Try this:
Of course, here it doesn't seem important, but what if you have 2 div with "display:inline-block" side by side ? The pretty printed html would render with an extra space between the 2 divs which is not the expected behaviour.
Shouldn't the outputSettings being copied to the cloned element ? Or the owner document being cloned as well as the cloned element ? Or at least, shouldn't we be provided a function to set outputSetting directly to an Element ? The owner document could be generated at that moment if needed ?
The text was updated successfully, but these errors were encountered: