File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
packages/experiment-tag/src Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,7 @@ import {
3333import { setMarketingCookie } from './util/cookie' ;
3434import { getInjectUtils } from './util/inject-utils' ;
3535import { VISUAL_EDITOR_SESSION_KEY , WindowMessenger } from './util/messenger' ;
36+ import { patchRemoveChild } from './util/patch' ;
3637import {
3738 getStorageItem ,
3839 setStorageItem ,
@@ -190,6 +191,7 @@ export class DefaultWebExperimentClient implements WebExperimentClient {
190191 if ( this . isRunning ) {
191192 return ;
192193 }
194+ patchRemoveChild ( ) ;
193195 const urlParams = getUrlParams ( ) ;
194196 this . isVisualEditorMode =
195197 urlParams [ 'VISUAL_EDITOR' ] === 'true' ||
Original file line number Diff line number Diff line change 1+ /**
2+ * Patch removeChild to avoid errors when removing nodes that are added
3+ * mutate/inject actions.
4+ */
5+ export const patchRemoveChild = ( ) => {
6+ HTMLElement . prototype . removeChild = function < T extends Node > ( n : T ) : T {
7+ if ( ! n || n . parentNode === this ) {
8+ return Node . prototype . removeChild . call ( this , n ) as T ;
9+ }
10+ return n ;
11+ } ;
12+ } ;
You can’t perform that action at this time.
0 commit comments