diff --git a/demo/index.jsx b/demo/index.jsx
index 980b96de74..aa90823d9c 100644
--- a/demo/index.jsx
+++ b/demo/index.jsx
@@ -1,197 +1,30 @@
-import { render, Component, Fragment } from 'preact';
-// import renderToString from 'preact-render-to-string';
-import './style.scss';
-import { Router, Link } from 'preact-router';
-import Pythagoras from './pythagoras';
-import Spiral from './spiral';
-import Reorder from './reorder';
-import Todo from './todo';
-import Fragments from './fragments';
-import Context from './context';
-import installLogger from './logger';
-import ProfilerDemo from './profiler';
-import KeyBug from './key_bug';
-import StateOrderBug from './stateOrderBug';
-import PeopleBrowser from './people';
-import StyledComp from './styled-components';
-import { initDevTools } from 'preact/devtools/src/devtools';
-import { initDebug } from 'preact/debug/src/debug';
-import DevtoolsDemo from './devtools';
-import SuspenseDemo from './suspense';
-import Redux from './redux';
-import TextFields from './textFields';
-import ReduxBug from './reduxUpdate';
-import SuspenseRouterBug from './suspense-router';
-import NestedSuspenseBug from './nested-suspense';
-import Contenteditable from './contenteditable';
-import { MobXDemo } from './mobx';
-import Zustand from './zustand';
-import ReduxToolkit from './redux_toolkit';
-
-let isBenchmark = /(\/spiral|\/pythagoras|[#&]bench)/g.test(
- window.location.href
-);
-if (!isBenchmark) {
- // eslint-disable-next-line no-console
- console.log('Enabling devtools and debug');
- initDevTools();
- initDebug();
-}
-
-// mobx-state-tree fix
-window.setImmediate = setTimeout;
-
-class Home extends Component {
- render() {
- return (
-
-
Hello
-
- );
- }
-}
-
-class DevtoolsWarning extends Component {
- onClick = () => {
- window.location.reload();
- };
-
- render() {
- return (
-
- );
- }
+import { render, h } from 'preact';
+import { useState, useEffect } from 'preact/hooks';
+// import './patch'
+
+const Button = props => {
+ return (
+
+ );
+};
+
+function App() {
+ const [, setValue] = useState(0);
+
+ useEffect(() => {
+ const interval = setInterval(() => setValue(v => v + 1), 1000);
+
+ return () => clearInterval(interval);
+ }, []);
+
+ return (
+ <>
+ Hello
+
+ >
+ );
}
-class App extends Component {
- render({ url }) {
- return (
-
-
-
-
-
-
-
-
-
-
- {!isBenchmark ? : }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- );
- }
-}
-
-function EmptyFragment() {
- return ;
-}
-
-// document.body.innerHTML = renderToString();
-// document.body.firstChild.setAttribute('is-ssr', 'true');
-
-installLogger(
- String(localStorage.LOG) === 'true' || location.href.match(/logger/),
- String(localStorage.CONSOLE) === 'true' || location.href.match(/console/)
-);
-
render(, document.body);
diff --git a/demo/patch.js b/demo/patch.js
new file mode 100644
index 0000000000..0d8eb51dc7
--- /dev/null
+++ b/demo/patch.js
@@ -0,0 +1,65 @@
+import { options } from 'preact';
+
+// Fix Preact rendering when Google Translate breaks the DOM
+const FONT_AS_TEXT = {
+ localName: {
+ value: null
+ },
+ nodeType: {
+ value: 3
+ },
+ data: {
+ get() {
+ return this._data;
+ },
+ set(v) {
+ v += '';
+ if (v === this._data) return;
+ const t = document.createTextNode((this._data = v));
+ this.parentNode.replaceChild(t, this);
+ this.__v.__e = t;
+ }
+ }
+};
+function check(child, ref) {
+ if (ref && ref.nodeType === 3 && child) {
+ let intercept = child.localName === 'msreadoutspan';
+ if (!intercept && child.localName === 'font') {
+ for (let i in child) {
+ if (i.startsWith('_gt_')) {
+ intercept = true;
+ break;
+ }
+ }
+ }
+ if (intercept) {
+ ref._font = child;
+ child._data = ref.data;
+ Object.defineProperties(child, FONT_AS_TEXT);
+ }
+ }
+}
+const ib = Element.prototype.insertBefore;
+Element.prototype.insertBefore = function (child, ref) {
+ check(child, ref);
+ return ib.apply(this, arguments);
+};
+const rc = Element.prototype.replaceChild;
+Element.prototype.replaceChild = function (child, ref) {
+ check(child, ref);
+ return rc.apply(this, arguments);
+};
+const oldDiffedHook = options.diffed;
+options.diffed = vnode => {
+ if (vnode.type === null && vnode.__e) {
+ const font = vnode.__e._font;
+ if (font) {
+ vnode.__e = font;
+ font.__v = vnode;
+ font.data = vnode.props;
+ }
+ }
+ if (oldDiffedHook) {
+ oldDiffedHook(vnode);
+ }
+};
diff --git a/src/diff/children.js b/src/diff/children.js
index 727a8a654e..e6cf18690d 100644
--- a/src/diff/children.js
+++ b/src/diff/children.js
@@ -117,7 +117,7 @@ export function diffChildren(
oldVNode._children === childVNode._children
) {
// @ts-expect-error olDom should be present on a DOM node
- if (oldDom && oldDom.nodeType === 1 && !oldDom.isConnected) {
+ if (oldDom && typeof childVNode.type == 'string' && !oldDom.isConnected) {
oldDom = getDomSibling(oldVNode);
}
oldDom = insert(childVNode, oldDom, parentDom);