Skip to content

Commit 8e53224

Browse files
mbostockjkenzer
andauthored
appendChild instead of append (#957)
* Change .append() to .appendChild() (#953) * Update plot.js to use .appendChild() rather than .append() * Refactor to use ternary and typeof check * appendChild fixes Co-authored-by: Josh Kenzer <[email protected]>
1 parent 3cf7cdb commit 8e53224

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/plot.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -222,11 +222,12 @@ export function plot(options = {}) {
222222
if (caption != null || legends.length > 0) {
223223
figure = document.createElement("figure");
224224
figure.style.maxWidth = "initial";
225-
figure.append(...legends, svg);
225+
for (const legend of legends) figure.appendChild(legend);
226+
figure.appendChild(svg);
226227
if (caption != null) {
227228
const figcaption = document.createElement("figcaption");
228-
figcaption.append(caption);
229-
figure.append(figcaption);
229+
figcaption.appendChild(caption instanceof Node ? caption : document.createTextNode(caption));
230+
figure.appendChild(figcaption);
230231
}
231232
}
232233

0 commit comments

Comments
 (0)