Skip to content

Commit 6b574b3

Browse files
committed
html JME function: only try to set data-interactive on element nodes
In particular, a plot produced by webR returns a list of nodes including comments and text nodes, which have no `setAttribute` method. This changes the `html` function so that it only tries to call `setAttribute` on element nodes.
1 parent e83728e commit 6b574b3

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

runtime/scripts/jme-builtins.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -342,7 +342,11 @@ newBuiltin('html',[TString],THTML,null, {
342342
var subber = new jme.variables.DOMcontentsubber(scope);
343343
subber.subvars(container);
344344
var nodes = Array.from(container.childNodes);
345-
nodes.forEach(node => node.setAttribute('data-interactive', 'false'));
345+
nodes.forEach(node => {
346+
if(node.nodeType == node.ELEMENT_NODE) {
347+
node.setAttribute('data-interactive', 'false');
348+
}
349+
});
346350
return new THTML(nodes);
347351
}
348352
});

0 commit comments

Comments
 (0)