Kaynağa Gözat

Fix incorrect loop with removal

dev1
Lyubomir Marinov 9 yıl önce
ebeveyn
işleme
dd76dd9925
1 değiştirilmiş dosya ile 13 ekleme ve 13 silme
  1. 13
    13
      modules/RTC/JitsiTrack.js

+ 13
- 13
modules/RTC/JitsiTrack.js Dosyayı Görüntüle

@@ -184,25 +184,25 @@ JitsiTrack.prototype.attach = function (container) {
184 184
 };
185 185
 
186 186
 /**
187
- * Removes the track from the passed HTML container.
188
- * @param container the HTML container. If <tt>null</tt> all containers are removed.
189
- *        A container can be 'video', 'audio' or 'object' HTML element instance
190
- *        to which this JitsiTrack is currently attached to.
187
+ * Removes this JitsiTrack from the passed HTML container.
188
+ *
189
+ * @param container the HTML container to detach from this JitsiTrack. If
190
+ * <tt>null</tt> or <tt>undefined</tt>, all containers are removed. A container
191
+ * can be a 'video', 'audio' or 'object' HTML element instance to which this
192
+ * JitsiTrack is currently attached.
191 193
  */
192 194
 JitsiTrack.prototype.detach = function (container) {
193
-    for(var i = 0; i < this.containers.length; i++)
194
-    {
195
-        if(!container)
196
-        {
197
-            RTCUtils.setVideoSrc(this.containers[i], null);
195
+    for (var cs = this.containers, i = cs.length - 1; i >= 0; --i) {
196
+        var c = cs[i];
197
+        if (!container) {
198
+            RTCUtils.setVideoSrc(c, null);
198 199
         }
199
-        if(!container || $(this.containers[i]).is($(container)))
200
-        {
201
-            this.containers.splice(i,1);
200
+        if (!container || $(c).is($(container))) {
201
+            cs.splice(i, 1);
202 202
         }
203 203
     }
204 204
 
205
-    if(container) {
205
+    if (container) {
206 206
         RTCUtils.setVideoSrc(container, null);
207 207
     }
208 208
 };

Loading…
İptal
Kaydet