From d9eafa21ad1d6ad340b5744d69e9fc68ce2083cb Mon Sep 17 00:00:00 2001 From: s-ol Date: Tue, 29 Oct 2019 14:18:16 +0100 Subject: add sandbox --- .../javascript/text$javascript -> mmm$dom.js | 24 ++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 root/sandbox/javascript/text$javascript -> mmm$dom.js (limited to 'root/sandbox/javascript/text$javascript -> mmm$dom.js') diff --git a/root/sandbox/javascript/text$javascript -> mmm$dom.js b/root/sandbox/javascript/text$javascript -> mmm$dom.js new file mode 100644 index 0000000..58deb23 --- /dev/null +++ b/root/sandbox/javascript/text$javascript -> mmm$dom.js @@ -0,0 +1,24 @@ +// a little helper function for creating DOM elements +const e = (elem, children) => { + const node = document.createElement(elem); + + if (typeof children === 'string') + node.innerText = children; + else + children.forEach(child => node.appendChild(child)); + + return node; +}; + +/* creating the equivalent of the following HTML directly as DOM content: + * + *
+ *

JavaScript

+ *

...

+ *
+ */ + +return e('article', [ + e('h1', 'JavaScript'), + e('p', 'JavaScript is supported natively in the browser but is not currently pre-rendered on the server.'), +]); -- cgit v1.2.3