Skip to content

Commit 1c8f511

Browse files
author
Avaer Kazmer
committed
Use xr-engine shadowing if possible
1 parent 453a0a6 commit 1c8f511

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

src/xr-engine.js

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -106,17 +106,18 @@ const XREngineProto = {
106106
win.ctx.getExtension(extensions[i]);
107107
}
108108

109-
/* if (!this.shadow) {
110-
this.shadow = this.attachShadow({mode: 'closed'});
109+
if (this._canShadow) {
110+
if (!this.shadow) {
111+
this.shadow = this.attachShadow({mode: 'closed'});
112+
}
113+
this.shadow.appendChild(win.canvas);
114+
} else {
115+
this.insertAdjacentElement('afterend', win.canvas);
111116
}
112-
this.shadow.appendChild(win.canvas); */
113117

114118
this.dispatchEvent(new MessageEvent('canvas', {
115119
data: win.canvas,
116120
}));
117-
if (!win.canvas.parentNode) {
118-
this.insertAdjacentElement('afterend', win.canvas);
119-
}
120121
}
121122
return win.ctx;
122123
};
@@ -239,12 +240,14 @@ const XREngineStatic = {
239240
class XREngine extends HTMLElement {
240241
constructor() {
241242
super();
243+
this._canShadow = true;
242244
this._constructor();
243245
}
244246
}
245247
class XREngineTemplate extends HTMLTemplateElement {
246248
constructor() {
247249
super();
250+
this._canShadow = false;
248251
this._constructor();
249252
}
250253
}

0 commit comments

Comments
 (0)