🩹 should invoke removeChild on original node while it not calling by micro app
This commit is contained in:
parent
385dc8c53a
commit
c9dff6fe42
|
|
@ -346,10 +346,12 @@ function getNewRemoveChild(
|
|||
headOrBodyRemoveChild: typeof HTMLElement.prototype.removeChild,
|
||||
containerConfigGetter: (element: HTMLElement) => ContainerConfig,
|
||||
target: DynamicDomMutationTarget,
|
||||
isInvokedByMicroApp: (element: HTMLElement) => boolean,
|
||||
) {
|
||||
return function removeChild<T extends Node>(this: HTMLHeadElement | HTMLBodyElement, child: T) {
|
||||
const { tagName } = child as any;
|
||||
if (!isHijackingTag(tagName)) return headOrBodyRemoveChild.call(this, child) as T;
|
||||
if (!isHijackingTag(tagName) || !isInvokedByMicroApp(child as any))
|
||||
return headOrBodyRemoveChild.call(this, child) as T;
|
||||
|
||||
try {
|
||||
let attachedElement: Node;
|
||||
|
|
@ -429,8 +431,18 @@ export function patchHTMLDynamicAppendPrototypeFunctions(
|
|||
HTMLHeadElement.prototype.removeChild === rawHeadRemoveChild &&
|
||||
HTMLBodyElement.prototype.removeChild === rawBodyRemoveChild
|
||||
) {
|
||||
HTMLHeadElement.prototype.removeChild = getNewRemoveChild(rawHeadRemoveChild, containerConfigGetter, 'head');
|
||||
HTMLBodyElement.prototype.removeChild = getNewRemoveChild(rawBodyRemoveChild, containerConfigGetter, 'body');
|
||||
HTMLHeadElement.prototype.removeChild = getNewRemoveChild(
|
||||
rawHeadRemoveChild,
|
||||
containerConfigGetter,
|
||||
'head',
|
||||
isInvokedByMicroApp,
|
||||
);
|
||||
HTMLBodyElement.prototype.removeChild = getNewRemoveChild(
|
||||
rawBodyRemoveChild,
|
||||
containerConfigGetter,
|
||||
'body',
|
||||
isInvokedByMicroApp,
|
||||
);
|
||||
}
|
||||
|
||||
return function unpatch() {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user