Skip to content

Commit 2e9304a

Browse files
committed
Golf some poral childs
1 parent b52475b commit 2e9304a

File tree

5 files changed

+16
-20
lines changed

5 files changed

+16
-20
lines changed

compat/src/portals.js

Lines changed: 12 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,14 @@ function Portal(props) {
3232
}
3333

3434
if (!_this._temp) {
35-
// Ensure the element has a mask for useId invocations
36-
let root = _this._vnode;
37-
while (root !== null && !root._mask && root._parent !== null) {
38-
root = root._parent;
39-
}
40-
4135
_this._container = container;
4236

4337
// Create a fake DOM parent node that manages a subset of `container`'s children:
4438
_this._temp = {
4539
nodeType: 1,
4640
parentNode: container,
4741
childNodes: [],
48-
_children: { _mask: root._mask },
4942
contains: () => true,
50-
// Technically this isn't needed
51-
appendChild(child) {
52-
this.childNodes.push(child);
53-
_this._container.appendChild(child);
54-
},
5543
insertBefore(child, before) {
5644
this.childNodes.push(child);
5745
_this._container.insertBefore(child, before);
@@ -63,11 +51,19 @@ function Portal(props) {
6351
};
6452
}
6553

66-
// Render our wrapping element into temp.
67-
render(
68-
createElement(ContextProvider, { context: _this.context }, props._vnode),
69-
_this._temp
54+
const element = createElement(
55+
ContextProvider,
56+
{ context: _this.context },
57+
props._vnode
7058
);
59+
// Ensure the element has a mask for useId invocations
60+
let root = _this._vnode;
61+
while (root !== null && !root._mask && root._parent !== null) {
62+
root = root._parent;
63+
}
64+
element._mask = root._mask;
65+
// Render our wrapping element into temp.
66+
render(element, _this._temp);
7167
}
7268

7369
/**

test/shared/createContext.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createElement, createContext } from '../../';
1+
import { createElement, createContext } from '../../src/index';
22
import { expect } from 'chai';
33

44
/** @jsx createElement */

test/shared/createElement.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createElement } from '../../';
1+
import { createElement } from '../../src/index';
22
import { expect } from 'chai';
33

44
const h = createElement;

test/shared/exports.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import {
1111
createRef,
1212
toChildArray,
1313
isValidElement
14-
} from '../../';
14+
} from '../../src/index';
1515
import { expect } from 'chai';
1616

1717
describe('preact', () => {

test/shared/isValidElement.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { createElement, isValidElement, Component } from '../../';
1+
import { createElement, isValidElement, Component } from '../../src/index';
22
import { expect } from 'chai';
33
import { isValidElementTests } from './isValidElementTests';
44

0 commit comments

Comments
 (0)