Skip to content

Commit 1411c2f

Browse files
author
Avaer Kazmer
committed
Bugfix owned xr-iframe tracking
1 parent ac471b2 commit 1411c2f

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

app.html

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -515,11 +515,10 @@
515515
if (landState) {
516516
// remove owned xr-iframes
517517

518-
const landXrIframe = root.childNodes[0];
519-
const ownedXrIframes = _getOwnedXrIframes(landXrIframe);
518+
const ownedXrIframes = Array.from(root.querySelectorAll('xr-iframe')).filter(xrIframe => /^owned:/.test(xrIframe.id));
520519
for (let i = 0; i < ownedXrIframes.length; i++) {
521520
const ownedXrIframe = ownedXrIframes[i];
522-
const match = ownedXrIframe.match(/^owned:(.*?)-/);
521+
const match = ownedXrIframe.id.match(/^owned:(.*?)-/);
523522
if (match) {
524523
const ownerId = match[1];
525524
if (ownerId === peerConnectionId) {
@@ -561,8 +560,19 @@
561560
break;
562561
}
563562
case 'removeChild': {
564-
const childNode = el.childNodes[key];
565-
el.removeChild(childNode);
563+
let match, childNode;
564+
if (typeof key === 'number' && key < el.childNodes.length) {
565+
childNode = el.childNodes[key];
566+
el.removeChild(childNode);
567+
} else if (
568+
typeof key === 'string' &&
569+
(match = key.match(/^#(.+)$/)) &&
570+
(childNode = Array.from(el.childNodes).find(node => node.id === match[1]))
571+
) {
572+
el.removeChild(childNode);
573+
} else {
574+
console.warn('remove missing child', keyPath, key);
575+
}
566576
break;
567577
}
568578
}

0 commit comments

Comments
 (0)