Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const { use, html, Internals, createTree, innerHTML } = require('diffhtml');
const { makeDOMNode } = require('quick-dom-node');
const { keys } = Object;
// Apply a transformation function against the Nodes to produce a string of
// markup.
use({ createNodeHook: vTree => makeDOMNode(vTree) });
// Use the same tasks for every run. Maybe in the future we'll allow for
// passing custom tasks.
const tasks = new Set(Internals.defaultTasks);
// Remove incompatible tasks, and replace them with serialization-compatible
// functions.
tasks.delete(Internals.tasks.reconcileTrees);
tasks.delete(Internals.tasks.syncTrees);
tasks.delete(Internals.tasks.patchNode);
tasks.delete(Internals.tasks.endAsPromise);
// Add a new reconcile trees function to ensure we are diffing against a tree
// instead of DOM Node.
tasks.add(function reconcileTrees(transaction) {
const { domNode, markup, options } = transaction;
// If we are in a render transaction where no markup was previously parsed
// then reconcile trees will attempt to create a tree based on the incoming
// markup (JSX/html/etc).
if (!transaction.newTree) {
transaction.newTree = createTree(markup);
}
const { use, html, Internals, createTree, innerHTML } = require('diffhtml');
const { makeDOMNode } = require('quick-dom-node');
const { keys } = Object;
// Apply a transformation function against the Nodes to produce a string of
// markup.
use({ createNodeHook: vTree => makeDOMNode(vTree) });
// Use the same tasks for every run. Maybe in the future we'll allow for
// passing custom tasks.
const tasks = new Set(Internals.defaultTasks);
// Remove incompatible tasks, and replace them with serialization-compatible
// functions.
tasks.delete(Internals.tasks.reconcileTrees);
tasks.delete(Internals.tasks.syncTrees);
tasks.delete(Internals.tasks.patchNode);
tasks.delete(Internals.tasks.endAsPromise);
// Add a new reconcile trees function to ensure we are diffing against a tree
// instead of DOM Node.
tasks.add(function reconcileTrees(transaction) {
const { domNode, markup, options } = transaction;
// If we are in a render transaction where no markup was previously parsed
// then reconcile trees will attempt to create a tree based on the incoming
// markup (JSX/html/etc).
if (!transaction.newTree) {
transaction.newTree = createTree(markup);
}
// Associate the old tree with this brand new transaction. Always ensure that
import { Internals } from 'diffhtml';
import { BLACKBOX_ATTRIBUTE } from '../constants';
import getNodeKey from './getNodeKey';
import endAsObservable from './endAsObservable';
import patchTask from './patchTask';
const { createNode } = Internals;
const { patchNode } = Internals.tasks;
/**
* Adds the key for every newly created tree.
*
* @param {VTree} tree - New tree.
* @returns {VTree} Updated tree.
*/
const createTreeHook = tree => {
tree.key = getNodeKey(tree);
return tree;
};
/**
* Create an instance of the render middleware for diffhtml.
*