Explorar el Código

fix(chat): polyfills for lib-jitsi-meet ChatRoom#onPresence (#2678)

The onPresence parsing was refactored to remove use of jQuery.
This exposed three methods not available in react-native:
ParentNode.children, ChildNode.remove, and
document.querySelectorAll. The querySelectorAll change could
be swapped for the already polyfilled querySelector, but
children and remove had to be added. The polyfills are based
on those supplied by MDN web docs, but modified to pass jitsi
linting.
j8
virtuacoplenny hace 7 años
padre
commit
1e0a3ceb74
Se han modificado 1 ficheros con 37 adiciones y 0 borrados
  1. 37
    0
      react/features/base/lib-jitsi-meet/native/polyfills-browser.js

+ 37
- 0
react/features/base/lib-jitsi-meet/native/polyfills-browser.js Ver fichero

@@ -195,6 +195,18 @@ function _visitNode(node, callback) {
195 195
                 };
196 196
             }
197 197
 
198
+            // Element.remove
199
+            //
200
+            // Required by:
201
+            // - lib-jitsi-meet ChatRoom#onPresence parsing
202
+            if (typeof elementPrototype.remove === 'undefined') {
203
+                elementPrototype.remove = function() {
204
+                    if (this.parentNode !== null) {
205
+                        this.parentNode.removeChild(this);
206
+                    }
207
+                };
208
+            }
209
+
198 210
             // Element.innerHTML
199 211
             //
200 212
             // Required by:
@@ -231,6 +243,31 @@ function _visitNode(node, callback) {
231 243
                     }
232 244
                 });
233 245
             }
246
+
247
+            // Element.children
248
+            //
249
+            // Required by:
250
+            // - lib-jitsi-meet ChatRoom#onPresence parsing
251
+            if (!elementPrototype.hasOwnProperty('children')) {
252
+                Object.defineProperty(elementPrototype, 'children', {
253
+                    get() {
254
+                        const nodes = this.childNodes;
255
+                        const children = [];
256
+                        let i = 0;
257
+                        let node = nodes[i];
258
+
259
+                        while (node) {
260
+                            if (node.nodeType === 1) {
261
+                                children.push(node);
262
+                            }
263
+                            i += 1;
264
+                            node = nodes[i];
265
+                        }
266
+
267
+                        return children;
268
+                    }
269
+                });
270
+            }
234 271
         }
235 272
 
236 273
         // FIXME There is a weird infinite loop related to console.log and

Loading…
Cancelar
Guardar