sinonjs / nise

Fake XHR and fake server
Other
109 stars 47 forks source link

responseType=document only supports XML not HTML #194

Open kaikiai opened 2 years ago

kaikiai commented 2 years ago

I discovered a problem with responseType='document' in FakeXHR. When using responseType in browser it is usable with XML and with HTML.

FakeXHR only works with XML

function convertResponseBody(responseType, contentType, body) {
....
} else if (responseType === "document") {
    if (isXmlContentType(contentType)) {
        return FakeXMLHttpRequest.parseXML(body);
    }
    return null;
}

should also be usable with content-type='text/html' and then not parsing with XML but instead use a parser with text/html as mime-type

fatso83 commented 1 year ago

Just file a PR to handle this. This seems fine.

stale[bot] commented 9 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.