Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(sandbox): Avoid dom repeated agent insertion #663

Merged
merged 2 commits into from
Mar 18, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion packages/browser-vm/src/dynamicNode/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,17 @@ export function makeElInjector(sandboxConfig: SandboxOptions) {
) => {
for (const name of methods) {
const fn = window.Element.prototype[name];
if (typeof fn !== 'function' || fn[__domWrapper__]) {
const symbolProxyName = Symbol.for(name + '_proxy');
const proxyFlag = window.Element.prototype[symbolProxyName];
if (typeof fn !== 'function' || fn[__domWrapper__] || proxyFlag) {
continue;
}
rawElementMethods[name] = fn;
const wrapper = builder(fn, name);
wrapper[__domWrapper__] = true;
window.Element.prototype[name] = wrapper;
// Avoid being re-mediated by the function
window.Element.prototype[symbolProxyName] = true;
}
};
rewrite(mountElementMethods, injector);
Expand Down
Loading