Skip to content

Commit

Permalink
dev: serializing unparented node on java
Browse files Browse the repository at this point in the history
  • Loading branch information
cbasguti committed May 29, 2023
1 parent fe06196 commit 79b8b4f
Showing 1 changed file with 18 additions and 9 deletions.
27 changes: 18 additions & 9 deletions ext/java/nokogiri/internals/SaveContextVisitor.java
Original file line number Diff line number Diff line change
Expand Up @@ -807,17 +807,26 @@ public int compare(Attr attr0, Attr attr1) {
// no-op
}

private boolean
isHtmlScript(Text text)
{
return htmlDoc && text.getParentNode().getNodeName().equals("script");
private boolean isHtmlScript(Text text) {
Node parentNode = text.getParentNode();
if (parentNode != null && parentNode.getNodeName().equals("script")) {
return htmlDoc;
} else {
System.out.println("getParentNode() returned null or parent node is not 'script'.");
return false;
}
}

private boolean
isHtmlStyle(Text text)
{
return htmlDoc && text.getParentNode().getNodeName().equals("style");

private boolean isHtmlStyle(Text text) {
Node parentNode = text.getParentNode();
if (parentNode != null && parentNode.getNodeName().equals("style")) {
return htmlDoc;
} else {
System.out.println("getParentNode() returned null or parent node is not 'style'.");
return false;
}
}


public boolean
enter(Text text)
Expand Down

0 comments on commit 79b8b4f

Please sign in to comment.