@remote-ui/core
Advanced tools
Comparing version 2.1.9 to 2.1.10
@@ -441,2 +441,4 @@ 'use strict'; | ||
function appendChild(container, child, internals, rootInternals) { | ||
var _currentParent$childr; | ||
const { | ||
@@ -451,4 +453,12 @@ nodes, | ||
const currentParent = child.parent; | ||
const existingIndex = (_currentParent$childr = currentParent === null || currentParent === void 0 ? void 0 : currentParent.children.indexOf(child)) !== null && _currentParent$childr !== void 0 ? _currentParent$childr : -1; | ||
return perform(container, rootInternals, { | ||
remote: channel => channel(types.ACTION_INSERT_CHILD, container.id, container.children.length, serializeChild(child)), | ||
remote: channel => { | ||
if (existingIndex >= 0) { | ||
channel(types.ACTION_REMOVE_CHILD, currentParent.id, existingIndex); | ||
} | ||
channel(types.ACTION_INSERT_CHILD, container.id, container.children.length, serializeChild(child)); | ||
}, | ||
local: () => { | ||
@@ -487,2 +497,4 @@ moveNodeToContainer(container, child, rootInternals); | ||
function insertChildBefore(container, child, before, internals, rootInternals) { | ||
var _currentParent$childr2; | ||
const { | ||
@@ -497,4 +509,12 @@ strict, | ||
const currentParent = child.parent; | ||
const existingIndex = (_currentParent$childr2 = currentParent === null || currentParent === void 0 ? void 0 : currentParent.children.indexOf(child)) !== null && _currentParent$childr2 !== void 0 ? _currentParent$childr2 : -1; | ||
return perform(container, rootInternals, { | ||
remote: channel => channel(types.ACTION_INSERT_CHILD, container.id, container.children.indexOf(before), serializeChild(child)), | ||
remote: channel => { | ||
if (existingIndex >= 0) { | ||
channel(types.ACTION_REMOVE_CHILD, currentParent.id, existingIndex); | ||
} | ||
channel(types.ACTION_INSERT_CHILD, container.id, container.children.indexOf(before), serializeChild(child)); | ||
}, | ||
local: () => { | ||
@@ -501,0 +521,0 @@ moveNodeToContainer(container, child, rootInternals); |
@@ -10,2 +10,6 @@ # Changelog | ||
## [2.1.10] - 2021-06-07 | ||
- Fixed an issue where children were not removed from an existing parent before being appended to a new one ([pull request](https://github.com/Shopify/remote-ui/pull/160)) | ||
## [2.1.9] - 2021-04-06 | ||
@@ -12,0 +16,0 @@ |
{ | ||
"name": "@remote-ui/core", | ||
"version": "2.1.9", | ||
"version": "2.1.10", | ||
"publishConfig": { | ||
@@ -18,4 +18,3 @@ "access": "public", | ||
"require": "./index.js" | ||
}, | ||
"./": "./" | ||
} | ||
}, | ||
@@ -27,3 +26,3 @@ "sideEffects": false, | ||
}, | ||
"gitHead": "7914688c33e57fb300ec416f57614e7eeccbbedf" | ||
"gitHead": "20ec8d2a729aa1094c95f6d6e7f4dc8d958f6e88" | ||
} |
@@ -621,4 +621,11 @@ import {RemoteComponentType} from '@remote-ui/types'; | ||
const currentParent = child.parent; | ||
const existingIndex = currentParent?.children.indexOf(child) ?? -1; | ||
return perform(container, rootInternals, { | ||
remote: (channel) => | ||
remote: (channel) => { | ||
if (existingIndex >= 0) { | ||
channel(ACTION_REMOVE_CHILD, currentParent.id, existingIndex); | ||
} | ||
channel( | ||
@@ -629,3 +636,4 @@ ACTION_INSERT_CHILD, | ||
serializeChild(child), | ||
), | ||
); | ||
}, | ||
local: () => { | ||
@@ -691,4 +699,11 @@ moveNodeToContainer(container, child, rootInternals); | ||
const currentParent = child.parent; | ||
const existingIndex = currentParent?.children.indexOf(child) ?? -1; | ||
return perform(container, rootInternals, { | ||
remote: (channel) => | ||
remote: (channel) => { | ||
if (existingIndex >= 0) { | ||
channel(ACTION_REMOVE_CHILD, currentParent.id, existingIndex); | ||
} | ||
channel( | ||
@@ -699,3 +714,4 @@ ACTION_INSERT_CHILD, | ||
serializeChild(child), | ||
), | ||
); | ||
}, | ||
local: () => { | ||
@@ -702,0 +718,0 @@ moveNodeToContainer(container, child, rootInternals); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
237131
3872