bug 590775, r=cdleary: default xml namespace = <<expr>>

This commit is contained in:
Dave Herman 2010-09-07 16:18:10 -07:00
parent 71de094573
commit 0039e6bd0d
2 changed files with 5 additions and 2 deletions

View File

@ -1884,11 +1884,11 @@ ASTSerializer::statement(JSParseNode *pn, Value *dst)
#if JS_HAS_XML_SUPPORT
case TOK_DEFAULT:
{
LOCAL_ASSERT(pn->pn_arity == PN_UNARY && PN_TYPE(pn->pn_kid) == TOK_STRING);
LOCAL_ASSERT(pn->pn_arity == PN_UNARY);
Value ns;
return literal(pn->pn_kid, &ns) &&
return expression(pn->pn_kid, &ns) &&
builder.xmlDefaultNamespace(ns, &pn->pn_pos, dst);
}
#endif

View File

@ -104,6 +104,7 @@ function xmlElt(contents) Pattern({ type: "XMLElement", contents: contents })
function xmlAttr(value) Pattern({ type: "XMLAttribute", value: value })
function xmlText(text) Pattern({ type: "XMLText", text: text })
function xmlPI(target, contents) Pattern({ type: "XMLProcessingInstruction", target: target, contents: contents })
function xmlDefNS(ns) Pattern({ type: "XMLDefaultDeclaration", namespace: ns })
function assertBlockStmt(src, patt) {
blockPatt(patt).assert(Reflect.parse(blockSrc(src)));
@ -757,6 +758,8 @@ assertExpr("<{foo}>text</{foo}>", xmlElt([xmlStartTag([xmlEscape(ident("foo"))])
xmlEndTag([xmlEscape(ident("foo"))])]));
assertExpr("<?xml?>", xmlPI("xml", ""));
assertExpr("<?xml version='1.0'?>", xmlPI("xml", "version='1.0'"));
assertDecl("default xml namespace = 'js';", xmlDefNS(lit("js")));
assertDecl("default xml namespace = foo;", xmlDefNS(ident("foo")));
// NOTE: We appear to be unable to test XMLNAME, XMLCDATA, and XMLCOMMENT.