Description
If you do an AJAX request for an XML document and then try to access the document using .responseXML, it fails to wrap it. Example:
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-type" content="text/html;charset=UTF-8" />
<script src="script.js"></script>
</head>
<body></body>
</html>
import('dart:html');
main() {
XMLHttpRequest a = new XMLHttpRequest();
a.open("GET", "http://localhost:8000/test.xml", true);
a.on.readyStateChange.add(void b(e) {
if (a.readyState == 4 && a.status == 200)
a.responseXML;
});
a.send();
}
When it gets to responseXML, it fails in wrapDocument:
static Document wrapDocument(raw) {
if (raw === null) { return null; }
if (raw.dartObjectLocalStorage !== null) {
return raw.dartObjectLocalStorage;
}
switch (raw.typeName) {
case "HTMLDocument":
return new DocumentWrappingImplementation._wrap(raw, raw.documentElement);
case "SVGDocument":
return new SVGDocumentWrappingImplementation._wrap(raw);
default:
throw new UnsupportedOperationException("Unknown type:" + raw.toString());
}
}
The problem is that the raw object is a base Document (i.e. XML), not HTMLDocument or SVGDocument. My guess is that we'll want an explicit XMLDocument type in dart:html to handle this.