Skip to content

Commit

Permalink
#93 - Fix QP.drawLines
Browse files Browse the repository at this point in the history
  • Loading branch information
JustinPealing committed Mar 1, 2021
1 parent f542b71 commit 9283acd
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
19 changes: 19 additions & 0 deletions examples/xslt_render.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example for html-query-plan</title>
<link rel="stylesheet" type="text/css" href="../css/qp.css" />
<script src="../dist/qp.js"></script>
</head>
<body>
<div id="container">
<!-- XSLT output goes here -->
</div>
</div>
</div>
<script>
QP.drawLines(document.getElementById("container"));
</script>
</body>
</html>
4 changes: 3 additions & 1 deletion src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,15 @@ class Node {
* Gets the xml for the whole query plan.
*/
get queryPlanXml(): Element {
return findAncestor(this.element, "qp-root").parentElement["xml"];
const root = findAncestor(this.element, "qp-root");
return root == null ? null : root.parentElement["xml"];
}

/**
* Gets the xml element corresponding to this node from the query plan xml.
*/
get nodeXml(): Element {
if (this.queryPlanXml == null) return null;
return getNodeXml(this.queryPlanXml, this.statementId, this.nodeId);
}

Expand Down
10 changes: 10 additions & 0 deletions test/nodes_test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,16 @@ describe("Node", () => {

});

it("Returns null if the nodeXml is not set", () => {

let element = document.createElement("div");
element.className = "qp-node";
let node = new Node(element);

assert.isNull(node.nodeXml);

});

});

});
Expand Down

0 comments on commit 9283acd

Please sign in to comment.