🐛 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) => {
|
||||
if (p === 'createElement') {
|
||||
return (...args: Parameters<typeof document.createElement>) => {
|
||||
const element = document.createElement(...args);
|
||||
// Must store the original createElement function to avoid error in nested sandbox
|
||||
const targetCreateElement = target.createElement;
|
||||
return function createElement(...args: Parameters<typeof document.createElement>) {
|
||||
const element = targetCreateElement.call(target, ...args);
|
||||
attachElementToProxy(element, sandbox.proxy);
|
||||
return element;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user