Better Native XML Support

Grant Husbands esdiscuss at
Tue Jan 17 09:57:48 PST 2012

David Bruant wrote:
> Have a look at quasis [1]. It provides what I'd consider to be a more
> generic and safer solution to E4X.

E4X is more than just data production, though. It added a number of
accessors/syntax for handling XML elements, many of which can be the
LHS of an assignment:
expr..ident // descendant selection
expr. at ident // attribute selection
expr.* // All-children selection
expr.(filter) // Filtering a set, with an implicit 'with'
@ident // At least within a filter, attribute selection
expr.var::ident // Using the namespace in var, descendant selection

In combination, they provide some concise ways of manipulating
document-free XML nodes, though with large number of downsides that
probably aren't worth covering in detail, here.

It might be worth considering bringing some of those constructs back
in a more generic and future-proof fashion in future versions of
ECMAScript. Or it might instead be worth considering allowing quasis
to be the LHS of an assignment, which would be useful and could then
cover more e4x use cases.

(I've removed es5-discuss from the recipients, since this is no longer
relevant to that)

Grant Husbands.

More information about the es-discuss mailing list