So I stripped out all the E4X static analysis and runtime and left only support for XML literals. I also defined a very basic interface for working with XML literals which lets you use XML to construct whatever objects you want.
Included is a basic pseudo-DOM implementation which should be good for most purposes (read: my purposes). But the beauty is that you can use XML literals on top of a more full-featured library like jsdom, or even on the client-side on top of the browser's native DOM.
Here's some examples of what we can do now:
marcel@marcel $ cat example.js
var u = require('util');
var div = <div>Click <a href="/something">here</a> to see something.</div>;
div.className = 'description';
u.log(div);
var untrusted_user_input = '<script>alert("xss!")</script>';
div = <div>{untrusted_user_input}</div>;
u.log(div);
var frag = <><li>one</li><li>two</li><li>three</li></>;
u.log(frag.toString());
u.log(<ol>{frag}</ol>);
u.log(frag);
marcel@marcel $ ./quick-run example.js
17 Dec 02:46:04 - <div class="description">Click <a href="/something">here</a> to see something.</div>
17 Dec 02:46:04 - <div><script>alert("xss!")</script></div>
17 Dec 02:46:04 - <li>one</li><li>two</li><li>three</li>
17 Dec 02:46:04 - <ol><li>one</li><li>two</li><li>three</li></ol>
17 Dec 02:46:04 -
This example is using the built-in simple DOM implementation, but it's easy enough to switch to jsdom if that's what you're in to:
var DOMXMLEnvironment = require('./runtime/dom-environment').DOMXMLEnvironment;
var dom = require('./jsdom/lib/jsdom/level2/core').dom.level2.core;
XMLEnvironment.set(new DOMXMLEnvironment(new dom.Document()));
From here on out any XML literals created will use the jsdom document you created.
For those of you who are curious here's an example of what the desugared code looks like--
Original: <node>Text <inner-node /></node>
Desugared: XMLEnvironment.get()._el({"type": 1, "open": "node", "close": "node", "attributes": void 0, "content": [{"type": 2, "value": "Text "}, {"type": 1, "open": "inner-node", "close": void 0, "attributes": void 0, "content": void 0}]});
That's about where the project is now. I wanted to see if any opinions have been changed since I shifted the focus of the project. E4X was pretty ridiculous and I think abandoning the spec was the right move. I think XML literals will be an extremely valuable tool for NodeJS developers who choose to embrace them.