Skip to content

dart:html XMLHttpRequest.responseXML throws an exception #1142

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
munificent opened this issue Jan 11, 2012 · 8 comments
Closed

dart:html XMLHttpRequest.responseXML throws an exception #1142

munificent opened this issue Jan 11, 2012 · 8 comments
Labels
closed-duplicate Closed in favor of an existing report web-libraries Issues impacting dart:html, etc., libraries
Milestone

Comments

@munificent
Copy link
Member

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.

@dgrove
Copy link
Contributor

dgrove commented Jan 17, 2012

Added Triaged label.

@jacob314
Copy link
Member

Unlike the SVGDocument case, we don't really want to pretend an XMLDocument is an HTMLDocument. One solution would be to reintroduce the original bare bones Document class but with a different name.

Ugly strawman:

class XMLDocument { ... }

class Document extends XMLDocument


Set owner to @nex3.

@vsmenon
Copy link
Member

vsmenon commented Apr 12, 2012

Removed Area-UI label.
Added Area-DOM label.

@vsmenon
Copy link
Member

vsmenon commented Jun 22, 2012

Set owner to @vsmenon.
Added this to the M1 milestone.

@iposva-google
Copy link
Contributor

Removed Area-DOM label.
Added Area-HTML label.

@vsmenon
Copy link
Member

vsmenon commented Aug 17, 2012

Removed the owner.

@blois
Copy link

blois commented Aug 31, 2012

This appears to be functioning correctly on the latest bits, though the hierarchy for Document is currently a bit odd.

@efortuna
Copy link
Contributor

efortuna commented Sep 5, 2012

The repro example above works now. However, more generally the '[XML]Document' implementing Document issue needs to be addressed. Merging with associated issue.


Added Duplicate label.
Marked as being merged into #3420.

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-duplicate Closed in favor of an existing report web-libraries Issues impacting dart:html, etc., libraries
Projects
None yet
Development

No branches or pull requests

7 participants