Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const snabbdom = require('snabbdom')
const patch = snabbdom.init([
require('snabbdom/modules/class').default,
require('snabbdom/modules/props').default,
require('snabbdom/modules/style').default,
require('snabbdom/modules/attributes').default,
require('snabbdom/modules/eventlisteners').default
])
const h = require('snabbdom/h').default
const omit = (o, fields) => Object.keys(o).reduce((a, b) => !fields.includes(b) ? Object.assign(a, {[b]: o[b]}) : a, {})
const shadowRoot = (child) => h('span', {}, child.map(deflate)) // Should be replaced with reference to parent instead?
const deflate = (child) => child ? (Array.isArray(child) ? shadowRoot(child) : child.tagName ? vtree(child) : child) : ''
function vtree (tree) {
const props = omit(tree, ['element', 'children', 'style', 'tagName'])
const children = tree.children && tree.children.map(deflate)
return h(tree.tagName, {props, style: tree.style, attrs: props.attrs || (props.properties || {}).attributes}, children)
}
function render (tree, node, oldTree) {
const newTree = vtree(tree)
if (oldTree) { patch(oldTree, newTree) } else { patch(node, newTree) }
return newTree
}
// import virtualize from 'snabbdom-virtualize/strings'
const snabbdom = require('snabbdom')
export const patch = snabbdom.init([ // Init patch function with chosen modules
require('snabbdom/modules/class').default, // makes it easy to toggle classes
require('snabbdom/modules/attributes').default,
require('snabbdom/modules/style').default, // handles styling on elements with support for animations
require('snabbdom/modules/props').default, // for setting properties on DOM elements
require('snabbdom/modules/dataset').default,
require('snabbdom/modules/eventlisteners').default // attaches event listeners
])
export const h = require('snabbdom/h').default // helper function for creating vnodes
export const toHTML = require('snabbdom-to-html') // helper function for convert vnode to HTML string
export const toVNode = require('snabbdom/tovnode').default // helper function for convert DOM to vnode
export const htmlToVNode = html => { // helper function for convert html to vnode
const wrapper = document.createElement('div')
wrapper.innerHTML = html
return toVNode(wrapper).children
}
// import virtualize from 'snabbdom-virtualize/strings'
const snabbdom = require('snabbdom')
export const patch = snabbdom.init([ // Init patch function with chosen modules
require('snabbdom/modules/class').default, // makes it easy to toggle classes
require('snabbdom/modules/attributes').default,
require('snabbdom/modules/style').default, // handles styling on elements with support for animations
require('snabbdom/modules/props').default, // for setting properties on DOM elements
require('snabbdom/modules/dataset').default,
require('snabbdom/modules/eventlisteners').default // attaches event listeners
])
export const h = require('snabbdom/h').default // helper function for creating vnodes
export const toHTML = require('snabbdom-to-html') // helper function for convert vnode to HTML string
export const toVNode = require('snabbdom/tovnode').default // helper function for convert DOM to vnode
export const htmlToVNode = html => { // helper function for convert html to vnode
const wrapper = document.createElement('div')
wrapper.innerHTML = html
return toVNode(wrapper).children
}
// Inits with common modules out of the box
// Also easier to use across multiple files
module.exports = require('./create')([
require('snabbdom/modules/attributes').default,
require('snabbdom/modules/eventlisteners').default,
require('snabbdom/modules/class').default,
require('snabbdom/modules/props').default,
require('snabbdom/modules/style').default
])
import { wait } from '@skatejs/bore';
import define from '@skatejs/define';
import Element, { h } from '..';
const Test = define(
class extends Element {
static modules = [
require('snabbdom/modules/attributes').default,
require('snabbdom/modules/eventlisteners').default,
require('snabbdom/modules/class').default,
require('snabbdom/modules/props').default,
require('snabbdom/modules/style').default,
require('snabbdom/modules/dataset').default
];
static props = { name: String };
name: string = 'World';
render() {
return h('span', `Hello, ${this.name}!`);
}
}
);
function testContent(text) {
return `<span>Hello, ${text}!</span>`;
import '../../src/cpp/';
import Perf from './Perf';
console.log('Preparing...');
const snabbdom = {
h: require('snabbdom/h').default,
patch: require('snabbdom').init([
require('snabbdom/modules/class').default,
require('snabbdom/modules/dataset').default,
require('snabbdom/modules/props').default,
require('snabbdom/modules/style').default,
require('snabbdom/modules/eventlisteners').default,
require('snabbdom/modules/attributes').default,
]),
};
window.snabbdom = snabbdom;
const config = {};
import('../compiled/wasm/app.wasm')
.then((wasm) => {
config.wasmBinary = new Uint8Array(wasm);
return import('../compiled/wasm/app.js').then(factory => {
const asmDom = factory(config);
delete asmDom.then;
return asmDom;
});
})
.then((app) => {
},{}],13:[function(require,module,exports){
var snabbdom = require('snabbdom');
var patch = snabbdom.init([
require('snabbdom/modules/class').default,
require('snabbdom/modules/attributes').default,
require('snabbdom/modules/props').default,
require('snabbdom/modules/style').default,
require('snabbdom/modules/eventlisteners').default,
require('snabbdom/modules/dataset').default
]);
snabbdom_h = require('snabbdom/h').default;
function stringifyEvent(e) {
const obj = {};
for (let k in e) {
obj[k] = e[k];
}
return JSON.stringify(obj, (k, v) => {
if (v instanceof Node) return 'Node';
if (v instanceof Window) return 'Window';
return v;
}
} else {
attrs[index] = value;
}
});
return snabbdomh.default(
name,
{
on, style, attrs, hook, class: sclass, key,
},
children,
);
}
const patch = snabbdom.init([
attributes.default,
style.default,
eventlisteners.default,
sclass.default,
]);
let renderPipeline = [];
function scheduleRender(node) {
renderPipeline.push(node);
const rendering = [...renderPipeline];
renderPipeline = [];
window.requestAnimationFrame(() => {
rendering.forEach(node => node.partialRender());
});
}