parent
85bfd0f77d
commit
d629c7aef8
2 changed files with 14 additions and 13 deletions
|
|
@ -99,6 +99,7 @@
|
|||
- render: fix when attrs change with `onbeforeupdate` returning false, then remaining the same on next redraw ([#2447](https://github.com/MithrilJS/mithril.js/pull/2447) [@isiahmeadows](https://github.com/isiahmeadows))
|
||||
- render: fix internal error when `onbeforeupdate` returns false and then true with new child tree ([#2447](https://github.com/MithrilJS/mithril.js/pull/2447) [@isiahmeadows](https://github.com/isiahmeadows))
|
||||
- route: arbitrary prefixes are properly supported now, including odd prefixes like `?#` and invalid prefixes like `#foo#bar` ([#2448](https://github.com/MithrilJS/mithril.js/pull/2448) [@isiahmeadows](https://github.com/isiahmeadows))
|
||||
- request: correct IE workaround for response type non-support ([#2449](https://github.com/MithrilJS/mithril.js/pull/2449) [@isiahmeadows](https://github.com/isiahmeadows))
|
||||
|
||||
---
|
||||
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ module.exports = function($window, Promise) {
|
|||
var method = args.method != null ? args.method.toUpperCase() : "GET"
|
||||
var body = args.body
|
||||
var assumeJSON = (args.serialize == null || args.serialize === JSON.serialize) && !(body instanceof $window.FormData)
|
||||
var responseType = args.responseType || (typeof args.extract === "function" ? "" : "json")
|
||||
|
||||
var xhr = new $window.XMLHttpRequest(),
|
||||
aborted = false,
|
||||
|
|
@ -97,7 +98,7 @@ module.exports = function($window, Promise) {
|
|||
}
|
||||
if (args.withCredentials) xhr.withCredentials = args.withCredentials
|
||||
if (args.timeout) xhr.timeout = args.timeout
|
||||
xhr.responseType = args.responseType || (typeof args.extract === "function" ? "" : "json")
|
||||
xhr.responseType = responseType
|
||||
|
||||
for (var key in args.headers) {
|
||||
if ({}.hasOwnProperty.call(args.headers, key)) {
|
||||
|
|
@ -121,18 +122,17 @@ module.exports = function($window, Promise) {
|
|||
// preferring `xhr.response` where possible/practical.
|
||||
var response = xhr.response, message
|
||||
|
||||
if (response == null) {
|
||||
try {
|
||||
response = xhr.responseText
|
||||
// Note: this snippet is intentionally *after*
|
||||
// `xhr.responseText` is accessed, since the
|
||||
// above will throw in modern browsers (thus
|
||||
// skipping the rest of this section). It's an
|
||||
// IE hack to detect and work around the lack of
|
||||
// native `responseType: "json"` support there.
|
||||
if (typeof args.extract !== "function" && xhr.responseType === "json") response = JSON.parse(response)
|
||||
}
|
||||
catch (e) { response = null }
|
||||
if (responseType === "json") {
|
||||
// For IE and Edge, which don't implement
|
||||
// `responseType: "json"`.
|
||||
if (!xhr.responseType && typeof args.extract !== "function") response = JSON.parse(xhr.responseText)
|
||||
} else if (!responseType || responseType === "text") {
|
||||
// Only use this default if it's text. If a parsed
|
||||
// document is needed on old IE and friends (all
|
||||
// unsupported), the user should use a custom
|
||||
// `config` instead. They're already using this at
|
||||
// their own risk.
|
||||
if (response == null) response = xhr.responseText
|
||||
}
|
||||
|
||||
if (typeof args.extract === "function") {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue