backpage
Advanced tools
Comparing version 0.0.1-9 to 0.0.1-10
@@ -103,4 +103,9 @@ import React from 'react'; | ||
updateHTML() { | ||
const content = this.content.cloneNode(true); | ||
const headStyles = content.ownerDocument.head.getElementsByTagName('style'); | ||
for (const style of headStyles) { | ||
content.prepend(style.cloneNode(true)); | ||
} | ||
this.tunnel.update({ | ||
content: this.content.cloneNode(true), | ||
content, | ||
}); | ||
@@ -107,0 +112,0 @@ } |
@@ -0,2 +1,3 @@ | ||
/// <reference types="react" resolution-mode="require"/> | ||
import type { BackPage } from '../backpage.js'; | ||
export declare const BackPageContext: import("react").Context<BackPage>; |
@@ -50,4 +50,4 @@ import { randomBytes } from 'crypto'; | ||
}, [colors, limit]); | ||
return (React.createElement("pre", { ...attrs }, recentLines.map(({ key, type, html }) => (React.createElement("div", { key: key, id: `${idPrefix}${key}`, className: type, dangerouslySetInnerHTML: { __html: html } }))))); | ||
return (React.createElement("pre", { ...attrs }, recentLines.map(({ key, type, html }) => (React.createElement("div", { key: key, "data-key": `${idPrefix}${key}`, className: type, dangerouslySetInnerHTML: { __html: html } }))))); | ||
} | ||
//# sourceMappingURL=console.js.map |
import { window } from './@jsdom.js'; | ||
Object.assign(global, { | ||
window, | ||
document: window.document, | ||
}); | ||
@@ -5,0 +6,0 @@ export * from './backpage.js'; |
@@ -31,3 +31,5 @@ import DiffMatchPatch from 'diff-match-patch'; | ||
function update({ title, content }) { | ||
document.title = title; | ||
if (document.title !== title) { | ||
document.title = title; | ||
} | ||
if (typeof content === 'string') { | ||
@@ -41,3 +43,13 @@ html = content; | ||
body.innerHTML = html; | ||
morphdom(document.body, body); | ||
morphdom(document.body, body, { | ||
getNodeKey: node => { | ||
var _a, _b; | ||
if (node instanceof HTMLElement) { | ||
return (_b = (_a = node.id) !== null && _a !== void 0 ? _a : node.dataset.key) !== null && _b !== void 0 ? _b : undefined; | ||
} | ||
else { | ||
return undefined; | ||
} | ||
}, | ||
}); | ||
} | ||
@@ -44,0 +56,0 @@ else { |
{ | ||
"name": "backpage", | ||
"version": "0.0.1-9", | ||
"version": "0.0.1-10", | ||
"repository": "https://github.com/vilicvane/backpage.git", | ||
@@ -60,4 +60,5 @@ "license": "MIT", | ||
"run-in-every": "^0.2.0", | ||
"styled-components": "^6.1.8", | ||
"typescript": "^5.3.3" | ||
} | ||
} |
@@ -5,2 +5,3 @@ import {window} from './@jsdom.js'; | ||
window, | ||
document: window.document, | ||
}); | ||
@@ -7,0 +8,0 @@ |
@@ -49,3 +49,5 @@ import DiffMatchPatch from 'diff-match-patch'; | ||
function update({title, content}: BackFrontUpdateMessage): void { | ||
document.title = title; | ||
if (document.title !== title) { | ||
document.title = title; | ||
} | ||
@@ -63,3 +65,11 @@ if (typeof content === 'string') { | ||
morphdom(document.body, body); | ||
morphdom(document.body, body, { | ||
getNodeKey: node => { | ||
if (node instanceof HTMLElement) { | ||
return node.id ?? node.dataset.key ?? undefined; | ||
} else { | ||
return undefined; | ||
} | ||
}, | ||
}); | ||
} else { | ||
@@ -66,0 +76,0 @@ document.body.innerHTML = 'An error occurred.'; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
186638
4293
9