Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 0 additions & 5 deletions compat/src/portals.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,11 +47,6 @@ function Portal(props) {
childNodes: [],
_children: { _mask: root._mask },
contains: () => true,
// Technically this isn't needed
appendChild(child) {
this.childNodes.push(child);
_this._container.appendChild(child);
},
insertBefore(child, before) {
this.childNodes.push(child);
_this._container.insertBefore(child, before);
Expand Down
38 changes: 38 additions & 0 deletions compat/test/browser/portals.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,44 @@ describe('Portal', () => {
);
});

it('should have unique ids for each portal, even when a new one shows up', () => {
let root = document.createElement('div');
let dialog = document.createElement('div');
dialog.id = 'container';

scratch.appendChild(root);
scratch.appendChild(dialog);

function Id() {
const id = useId();
return id;
}

function Dialog(props) {
return <Id />;
}

function App(props) {
return (
<div>
<Id />
{createPortal(<Dialog />, dialog)}
{props.renderPortal && createPortal(<Dialog />, dialog)}
</div>
);
}

render(<App />, root);
expect(scratch.innerHTML).to.equal(
'<div><div>P0-0</div></div><div id="container">P0-1</div>'
);

render(<App renderPortal={true} />, root);
expect(scratch.innerHTML).to.equal(
'<div><div>P0-0</div></div><div id="container">P0-1P0-2</div>'
);
});

it('should unmount Portal', () => {
let root = document.createElement('div');
let dialog = document.createElement('div');
Expand Down
2 changes: 1 addition & 1 deletion test/shared/createContext.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createElement, createContext } from '../../';
import { createElement, createContext } from '../../src/index';
import { expect } from 'chai';

/** @jsx createElement */
Expand Down
2 changes: 1 addition & 1 deletion test/shared/createElement.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createElement } from '../../';
import { createElement } from '../../src/index';
import { expect } from 'chai';

const h = createElement;
Expand Down
2 changes: 1 addition & 1 deletion test/shared/exports.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
createRef,
toChildArray,
isValidElement
} from '../../';
} from '../../src/index';
import { expect } from 'chai';

describe('preact', () => {
Expand Down
2 changes: 1 addition & 1 deletion test/shared/isValidElement.test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createElement, isValidElement, Component } from '../../';
import { createElement, isValidElement, Component } from '../../src/index';
import { expect } from 'chai';
import { isValidElementTests } from './isValidElementTests';

Expand Down
Loading