Skip to content

Commit

Permalink
Clean up scratch DOM after tests (#1701)
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewiggins authored and marvinhagemeister committed Jun 11, 2019
1 parent 1fbd272 commit 1298fb4
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
6 changes: 4 additions & 2 deletions compat/test/browser/portals.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { createElement as h, render, createPortal, useState, Component } from '../../src';
import { setupScratch } from '../../../test/_util/helpers';
import { setupRerender, teardown } from 'preact/test-utils';
import { setupScratch, teardown } from '../../../test/_util/helpers';
import { setupRerender } from 'preact/test-utils';
/* eslint-disable react/jsx-boolean-value, react/display-name, prefer-arrow-callback */

/** @jsx h */
Expand Down Expand Up @@ -29,6 +29,8 @@ describe('Portal', () => {
render(<Foo>foobar</Foo>, scratch);

expect(root.innerHTML).to.equal('foobar');

root.parentNode.removeChild(root);
});

it('should insert the portal', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/internal.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export interface Options extends preact.Options {
/** Attach a hook that is invoked before render, mainly to check the arguments. */
_root?(vnode: preact.ComponentChild, parent: Element | Document | ShadowRoot | DocumentFragment): void;
/** Attach a hook that is invoked before a vnode is diffed. */
diff?(vnode: VNode): void;
_diff?(vnode: VNode): void;
/** Attach a hook that is invoked after a tree was mounted or was updated. */
_commit?(vnode: VNode): void;
/** Attach a hook that is invoked before a vnode has rendered. */
Expand Down
2 changes: 2 additions & 0 deletions test/browser/render.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -1017,6 +1017,8 @@ describe('render()', () => {
render(<div id="a">new</div>, newScratch, newScratch.querySelector('#a'));
expect(newScratch.innerHTML).to.equal('<div id="a">new</div>');
expect(unmount).to.be.calledOnce;

newScratch.parentNode.removeChild(newScratch);
});

it('should render multiple render roots in one parentDom', () => {
Expand Down

0 comments on commit 1298fb4

Please sign in to comment.