Fix: fetch text in Chrome 49
This commit is contained in:
parent
8934ee6e1b
commit
6435985fe6
|
@ -54,6 +54,12 @@
|
|||
}
|
||||
|
||||
function fetchText(url) {
|
||||
// XHR throws in Chrome 49
|
||||
// FIXME: choose a correct version
|
||||
// https://github.com/openstyles/stylus/issues/560
|
||||
if (getChromeVersion() <= 49) {
|
||||
return fetch(url).then(r => r.text());
|
||||
}
|
||||
return new Promise((resolve, reject) => {
|
||||
// you can't use fetch in Chrome under 'file:' protocol
|
||||
const xhr = new XMLHttpRequest();
|
||||
|
@ -64,6 +70,11 @@
|
|||
});
|
||||
}
|
||||
|
||||
function getChromeVersion() {
|
||||
const match = navigator.userAgent.match(/chrome\/(\d+)/i);
|
||||
return match && Number(match[1]);
|
||||
}
|
||||
|
||||
function start() {
|
||||
timer = timer || setTimeout(check, DELAY);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user