Sfoglia il codice sorgente

[RN] Remove no longer needed fetch API fallback

j8
Saúl Ibarra Corretgé 8 anni fa
parent
commit
c0f648b1ab
1 ha cambiato i file con 3 aggiunte e 30 eliminazioni
  1. 3
    30
      react/features/base/util/loadScript.native.js

+ 3
- 30
react/features/base/util/loadScript.native.js Vedi File

1
 /**
1
 /**
2
  * Loads a script from a specific URL. React Native cannot load a JS
2
  * Loads a script from a specific URL. React Native cannot load a JS
3
- * file/resource/URL via a <script> HTML element, so the implementation
4
- * fetches the specified src as plain text (e.g. via XMLHttpRequest) and then
3
+ * file/resource/URL via a <script> HTML element, so the implementation
4
+ * fetches the specified src as plain text using fetch() and then
5
  * evaluates the fetched string as JavaScript code (i.e. via the {@link eval}
5
  * evaluates the fetched string as JavaScript code (i.e. via the {@link eval}
6
  * function).
6
  * function).
7
  *
7
  *
10
  * @returns {void}
10
  * @returns {void}
11
  */
11
  */
12
 export function loadScript(url) {
12
 export function loadScript(url) {
13
-    let fetch;
14
-    const method = 'GET';
15
-
16
-    // Prefer the Fetch API. Apart from the fact that we're fetching the
17
-    // specified script as a static resource, the Fetch API provides more
18
-    // detailed errors.
19
-    if (typeof (fetch = window.fetch) === 'function') {
20
-        fetch = fetch(url, { method });
21
-    } else {
22
-        // Otherwise, fall back to the XMLHttpRequest API.
23
-        fetch
24
-            = new Promise(resolve => {
25
-                const xhr = new XMLHttpRequest();
26
-
27
-                xhr.responseType = 'text';
28
-
29
-                xhr.onreadystatechange = () => {
30
-                    if (xhr.readyState === 4) {
31
-                        resolve(xhr);
32
-                    }
33
-                };
34
-
35
-                xhr.open(method, url, /* async */ true);
36
-                xhr.send();
37
-            });
38
-    }
39
-
40
     return (
13
     return (
41
-        fetch
14
+        fetch(url, { method: 'GET' })
42
             .then(response => {
15
             .then(response => {
43
                 switch (response.status) {
16
                 switch (response.status) {
44
                 case 200:
17
                 case 200:

Loading…
Annulla
Salva