Add support for loading cross origin images using proxy

This commit is contained in:
Niklas von Hertzen
2017-09-04 23:36:19 +08:00
parent c2b7ed9c42
commit aa47a3a3a6
10 changed files with 122 additions and 17 deletions

View File

@@ -59,9 +59,9 @@ const testBase64 = (document: Document, src: string): Promise<boolean> => {
});
};
const testCORS = () => {
return typeof new Image().crossOrigin !== 'undefined';
};
const testCORS = () => typeof new Image().crossOrigin !== 'undefined';
const testResponseType = () => typeof new XMLHttpRequest().responseType === 'string';
const testSVG = document => {
const img = new Image();
@@ -156,6 +156,20 @@ const FEATURES = {
const value = testCORS();
Object.defineProperty(FEATURES, 'SUPPORT_CORS_IMAGES', {value});
return value;
},
// $FlowFixMe - get/set properties not yet supported
get SUPPORT_RESPONSE_TYPE() {
'use strict';
const value = testResponseType();
Object.defineProperty(FEATURES, 'SUPPORT_RESPONSE_TYPE', {value});
return value;
},
// $FlowFixMe - get/set properties not yet supported
get SUPPORT_CORS_XHR() {
'use strict';
const value = 'withCredentials' in new XMLHttpRequest();
Object.defineProperty(FEATURES, 'SUPPORT_CORS_XHR', {value});
return value;
}
};