@@ -16,36 +16,7 @@ import { SkateElement } from './base-skate-element';
1616
1717/** @jsx h */
1818
19- import preact , { h , render } from 'preact' ;
20-
21- // TODO make this a Symbol() when it's supported.
22- const preactNodeName = '__preactNodeName' ;
23-
24- let oldVnode ;
25-
26- function newVnode ( vnode ) {
27- const fn = vnode . nodeName ;
28- if ( fn && fn . prototype instanceof HTMLElement ) {
29- if ( ! fn [ preactNodeName ] ) {
30- const prefix = fn . name ;
31- customElements . define (
32- ( fn [ preactNodeName ] = name ( prefix ) ) ,
33- class extends fn { }
34- ) ;
35- }
36- vnode . nodeName = fn [ preactNodeName ] ;
37- }
38- return vnode ;
39- }
40-
41- function setupPreact ( ) {
42- oldVnode = preact . options . vnode ;
43- preact . options . vnode = newVnode ;
44- }
45-
46- function teardownPreact ( ) {
47- preact . options . vnode = oldVnode ;
48- }
19+ import { h , render } from 'preact' ;
4920
5021export class SkatePreactElement extends SkateElement {
5122 get props ( ) {
@@ -55,23 +26,16 @@ export class SkatePreactElement extends SkateElement {
5526 }
5627
5728 renderer ( root , call ) {
58- setupPreact ( ) ;
5929 this . _renderRoot = root ;
60- this . _preactDom = render (
61- call ( ) ,
62- root ,
63- this . _preactDom || root . childNodes [ 0 ]
64- ) ;
65- teardownPreact ( ) ;
30+ render ( call ( ) , root ) ;
6631 }
6732
6833 disconnectedCallback ( ) {
6934 this . disconnecting && this . disconnecting ( ) ;
7035 super . disconnectedCallback && super . disconnectedCallback ( ) ;
7136 this . disconnected && this . disconnected ( ) ;
7237 // Render null to unmount. See https://github.com/skatejs/skatejs/pull/1432#discussion_r183381359
73- this . _preactDom = render ( null , this . _renderRoot , this . _preactDom ) ;
74- this . _renderRoot = null ;
38+ render ( null , this . _renderRoot ) ;
7539
7640 this . __storeUnsubscribe && this . __storeUnsubscribe ( ) ;
7741
0 commit comments