🐛 compatible with nested sandbox to avoid stack overflow while createElement calling (#2414)
This commit is contained in:
parent
901dac8c7b
commit
bcfc96cd62
|
|
@ -50,8 +50,10 @@ function patchDocument(cfg: { sandbox: SandBox; speedy: boolean }) {
|
||||||
},
|
},
|
||||||
get: (target, p) => {
|
get: (target, p) => {
|
||||||
if (p === 'createElement') {
|
if (p === 'createElement') {
|
||||||
return (...args: Parameters<typeof document.createElement>) => {
|
// Must store the original createElement function to avoid error in nested sandbox
|
||||||
const element = document.createElement(...args);
|
const targetCreateElement = target.createElement;
|
||||||
|
return function createElement(...args: Parameters<typeof document.createElement>) {
|
||||||
|
const element = targetCreateElement.call(target, ...args);
|
||||||
attachElementToProxy(element, sandbox.proxy);
|
attachElementToProxy(element, sandbox.proxy);
|
||||||
return element;
|
return element;
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user