From cb6a00f0e0fec35c58f8ba83fbc775bac961ea90 Mon Sep 17 00:00:00 2001 From: jdecroock Date: Wed, 15 Feb 2023 16:40:04 +0100 Subject: [PATCH 1/3] fix react-frame-component by supporting nullish portals --- compat/src/portals.js | 57 +++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 29 deletions(-) diff --git a/compat/src/portals.js b/compat/src/portals.js index 45f5d3f360..c543651db2 100644 --- a/compat/src/portals.js +++ b/compat/src/portals.js @@ -33,39 +33,38 @@ function Portal(props) { // When props.vnode is undefined/false/null we are dealing with some kind of // conditional vnode. This should not trigger a render. - if (props._vnode) { - if (!_this._temp) { - _this._container = container; + if (!_this._temp) { + _this._container = container; - // Create a fake DOM parent node that manages a subset of `container`'s children: - _this._temp = { - nodeType: 1, - parentNode: container, - childNodes: [], - appendChild(child) { - this.childNodes.push(child); - _this._container.appendChild(child); - }, - insertBefore(child, before) { - this.childNodes.push(child); - _this._container.appendChild(child); - }, - removeChild(child) { - this.childNodes.splice(this.childNodes.indexOf(child) >>> 1, 1); - _this._container.removeChild(child); - } - }; - } - - // Render our wrapping element into temp. - render( - createElement(ContextProvider, { context: _this.context }, props._vnode), - _this._temp - ); + // Create a fake DOM parent node that manages a subset of `container`'s children: + _this._temp = { + nodeType: 1, + parentNode: container, + childNodes: [], + appendChild(child) { + this.childNodes.push(child); + _this._container.appendChild(child); + }, + insertBefore(child, before) { + this.childNodes.push(child); + _this._container.appendChild(child); + }, + removeChild(child) { + this.childNodes.splice(this.childNodes.indexOf(child) >>> 1, 1); + _this._container.removeChild(child); + } + }; } + + // Render our wrapping element into temp. + render( + createElement(ContextProvider, { context: _this.context }, props._vnode), + _this._temp + ); + // When we come from a conditional render, on a mounted // portal we should clear the DOM. - else if (_this._temp) { + if (!props._vnode && _this._temp) { _this.componentWillUnmount(); } } From 06e3fee9419b93d25393fb358da9edde4f2fdf20 Mon Sep 17 00:00:00 2001 From: Jovi De Croock Date: Fri, 17 Feb 2023 09:56:46 +0100 Subject: [PATCH 2/3] fixes --- compat/src/portals.js | 6 ------ 1 file changed, 6 deletions(-) diff --git a/compat/src/portals.js b/compat/src/portals.js index c543651db2..aecc5f587c 100644 --- a/compat/src/portals.js +++ b/compat/src/portals.js @@ -61,12 +61,6 @@ function Portal(props) { createElement(ContextProvider, { context: _this.context }, props._vnode), _this._temp ); - - // When we come from a conditional render, on a mounted - // portal we should clear the DOM. - if (!props._vnode && _this._temp) { - _this.componentWillUnmount(); - } } /** From 4980724b69929ebebc62c69b578cc81e9e9261fb Mon Sep 17 00:00:00 2001 From: Jovi De Croock Date: Wed, 15 Mar 2023 08:28:39 +0100 Subject: [PATCH 3/3] Update portals.js --- compat/src/portals.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/compat/src/portals.js b/compat/src/portals.js index aecc5f587c..49af3adee7 100644 --- a/compat/src/portals.js +++ b/compat/src/portals.js @@ -31,8 +31,6 @@ function Portal(props) { _this.componentWillUnmount(); } - // When props.vnode is undefined/false/null we are dealing with some kind of - // conditional vnode. This should not trigger a render. if (!_this._temp) { _this._container = container;