@bigbinary/neeto-commons-frontend 4.13.100 → 4.13.102

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,78 @@
1
+ 'use strict';
2
+
3
+ /* eslint-disable no-console */
4
+ // Monkey-patches Node.prototype.removeChild and insertBefore to prevent
5
+ // crashes caused by external DOM mutations conflicting with React's virtual
6
+ // DOM reconciliation.
7
+ //
8
+ // Problem:
9
+ // React maintains references to DOM nodes in its virtual DOM. When external
10
+ // libraries or browser features modify or remove those nodes before React's
11
+ // own cleanup runs, React calls removeChild/insertBefore on nodes that no
12
+ // longer exist in the expected parent, causing a crash:
13
+ // - WebKit/iOS: "NotFoundError: The object can not be found here"
14
+ // - Blink: "Failed to execute 'removeChild' on 'Node'"
15
+ //
16
+ // Known triggers:
17
+ // 1. @tippyjs/react portals — @tippyjs/react uses a hybrid DOM model:
18
+ // React renders content into a container via createPortal(), but
19
+ // tippy.js owns the container element and manages its attachment to
20
+ // document.body. On unmount (e.g., route navigation via history.push),
21
+ // tippy.js's destroy() removes the container from the DOM via
22
+ // removeChild(), while React's reconciler is also trying to clean up
23
+ // the portal children inside that same container. If tippy.js removes
24
+ // the container first, React's subsequent removeChild calls fail
25
+ // because the nodes are no longer under the expected parent.
26
+ // 2. Browser translation — Google Translate replaces text nodes with <font>
27
+ // elements. React still holds references to the original text nodes and
28
+ // crashes when trying to remove them.
29
+ //
30
+ // What this patch does:
31
+ // Before calling removeChild/insertBefore, it checks if the node actually
32
+ // belongs to the expected parent. If not, it logs a console.error and
33
+ // returns early instead of crashing the app.
34
+ //
35
+ // Side effect:
36
+ // If application code has a legitimate bug where removeChild is called on
37
+ // the wrong parent, this patch will log an error instead of throwing. The
38
+ // bug will still be visible in the console but won't crash the page. In
39
+ // practice this is rare — removeChild is called by React's internals, not
40
+ // application code, and the only time the parent mismatch occurs is when
41
+ // something external has moved or removed the node.
42
+ //
43
+ // Recommended by Dan Abramov (React core team):
44
+ // https://github.com/facebook/react/issues/11538#issuecomment-417504600
45
+
46
+ function patchDomForExternalMutations() {
47
+ if (typeof Node !== "function" || !Node.prototype) return;
48
+ if (Node.prototype.__neetoPatched) return;
49
+ Object.defineProperty(Node.prototype, "__neetoPatched", {
50
+ value: true,
51
+ enumerable: false,
52
+ configurable: false,
53
+ writable: false
54
+ });
55
+ var originalRemoveChild = Node.prototype.removeChild;
56
+ Node.prototype.removeChild = function (child) {
57
+ if (child.parentNode !== this) {
58
+ if (console) {
59
+ console.error("Cannot remove a child from a different parent", child, this);
60
+ }
61
+ return child;
62
+ }
63
+ return originalRemoveChild.apply(this, arguments);
64
+ };
65
+ var originalInsertBefore = Node.prototype.insertBefore;
66
+ Node.prototype.insertBefore = function (newNode, referenceNode) {
67
+ if (referenceNode && referenceNode.parentNode !== this) {
68
+ if (console) {
69
+ console.error("Cannot insert before a reference node from a different parent", referenceNode, this);
70
+ }
71
+ return newNode;
72
+ }
73
+ return originalInsertBefore.apply(this, arguments);
74
+ };
75
+ }
76
+
77
+ module.exports = patchDomForExternalMutations;
78
+ //# sourceMappingURL=domPatch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domPatch.js","sources":["../../../src/initializers/domPatch.js"],"sourcesContent":["/* eslint-disable no-console */\n// Monkey-patches Node.prototype.removeChild and insertBefore to prevent\n// crashes caused by external DOM mutations conflicting with React's virtual\n// DOM reconciliation.\n//\n// Problem:\n// React maintains references to DOM nodes in its virtual DOM. When external\n// libraries or browser features modify or remove those nodes before React's\n// own cleanup runs, React calls removeChild/insertBefore on nodes that no\n// longer exist in the expected parent, causing a crash:\n// - WebKit/iOS: \"NotFoundError: The object can not be found here\"\n// - Blink: \"Failed to execute 'removeChild' on 'Node'\"\n//\n// Known triggers:\n// 1. @tippyjs/react portals — @tippyjs/react uses a hybrid DOM model:\n// React renders content into a container via createPortal(), but\n// tippy.js owns the container element and manages its attachment to\n// document.body. On unmount (e.g., route navigation via history.push),\n// tippy.js's destroy() removes the container from the DOM via\n// removeChild(), while React's reconciler is also trying to clean up\n// the portal children inside that same container. If tippy.js removes\n// the container first, React's subsequent removeChild calls fail\n// because the nodes are no longer under the expected parent.\n// 2. Browser translation — Google Translate replaces text nodes with <font>\n// elements. React still holds references to the original text nodes and\n// crashes when trying to remove them.\n//\n// What this patch does:\n// Before calling removeChild/insertBefore, it checks if the node actually\n// belongs to the expected parent. If not, it logs a console.error and\n// returns early instead of crashing the app.\n//\n// Side effect:\n// If application code has a legitimate bug where removeChild is called on\n// the wrong parent, this patch will log an error instead of throwing. The\n// bug will still be visible in the console but won't crash the page. In\n// practice this is rare — removeChild is called by React's internals, not\n// application code, and the only time the parent mismatch occurs is when\n// something external has moved or removed the node.\n//\n// Recommended by Dan Abramov (React core team):\n// https://github.com/facebook/react/issues/11538#issuecomment-417504600\n\nexport default function patchDomForExternalMutations() {\n if (typeof Node !== \"function\" || !Node.prototype) return;\n\n if (Node.prototype.__neetoPatched) return;\n\n Object.defineProperty(Node.prototype, \"__neetoPatched\", {\n value: true,\n enumerable: false,\n configurable: false,\n writable: false,\n });\n\n const originalRemoveChild = Node.prototype.removeChild;\n Node.prototype.removeChild = function (child) {\n if (child.parentNode !== this) {\n if (console) {\n console.error(\n \"Cannot remove a child from a different parent\",\n child,\n this\n );\n }\n\n return child;\n }\n\n return originalRemoveChild.apply(this, arguments);\n };\n\n const originalInsertBefore = Node.prototype.insertBefore;\n Node.prototype.insertBefore = function (newNode, referenceNode) {\n if (referenceNode && referenceNode.parentNode !== this) {\n if (console) {\n console.error(\n \"Cannot insert before a reference node from a different parent\",\n referenceNode,\n this\n );\n }\n\n return newNode;\n }\n\n return originalInsertBefore.apply(this, arguments);\n };\n}\n"],"names":["patchDomForExternalMutations","Node","prototype","__neetoPatched","Object","defineProperty","value","enumerable","configurable","writable","originalRemoveChild","removeChild","child","parentNode","console","error","apply","arguments","originalInsertBefore","insertBefore","newNode","referenceNode"],"mappings":";;AAAA;AACA;AACA;AACA;AACA;AACA;AACA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DM,aAAa,EACb,IACF,CAAC;AACH;AAEA,MAAA,OAAOD,OAAO;AAChB;AAEA,IAAA,OAAOF,oBAAoB,CAACF,KAAK,CAAC,IAAI,EAAEC,SAAS,CAAC;GACnD;AACH;;;;"}
@@ -2,6 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
+ var toConsumableArray = require('../toConsumableArray-tBKHqzE3.js');
5
6
  var index = require('../index-bFmfHzbL.js');
6
7
  var i18next = require('i18next');
7
8
  var ramda = require('ramda');
@@ -11,11 +12,11 @@ var initializers_constants = require('./constants.js');
11
12
  var initializers_utils_customFormatters = require('./utils/customFormatters.js');
12
13
  var initializers_utils_customPostProcessors = require('./utils/customPostProcessors.js');
13
14
  var initializers_utils_utils = require('./utils/utils.js');
15
+ require('../unsupportedIterableToArray-BoHMiKNA.js');
14
16
  require('../_commonjsHelpers-BJu3ubxk.js');
15
17
  require('dompurify');
16
18
  require('../typeof-D4ZZ_FlZ.js');
17
19
  require('../slicedToArray-BcL7fKuL.js');
18
- require('../unsupportedIterableToArray-BoHMiKNA.js');
19
20
 
20
21
  function _classCallCheck(a, n) {
21
22
  if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
@@ -522,8 +523,8 @@ var initializeI18n = /*#__PURE__*/function () {
522
523
  },
523
524
  postProcess: [initializers_utils_customPostProcessors.sentenceCaseProcessor.name],
524
525
  detection: {
525
- order: ["querystring", "htmlTag", "navigator", "cookie"],
526
- caches: ["cookie"],
526
+ order: ["querystring", "htmlTag", "navigator"].concat(toConsumableArray._toConsumableArray(initializers_constants.IS_CHROME_EXTENSION ? [] : ["cookie"])),
527
+ caches: initializers_constants.IS_CHROME_EXTENSION ? [] : ["cookie"],
527
528
  lookupQuerystring: "lang",
528
529
  lookupCookie: "lang"
529
530
  }