Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
elementVoid,
text,
attributes,
symbols,
applyProp,
applyAttr,
notifications,
skip,
currentElement
} from 'incremental-dom'
import { getTagName, getCustomElement } from './src/core.js';
// configure incremental-dom attributes
attributes.class = applyAttr
attributes.is = (...args) => (applyAttr(...args), applyProp(...args))
attributes[symbols.default] = applyProp
// track aspects creation
// notifications.nodesCreated = function (nodes) {
// console.log(nodes)
// }
// build vdom
html.h = function h(target, props={}, ...children) {
let use, propsArr = []
let staticProps = []
let is, tag, classes = [], id, constructor
if (typeof target === 'function') {
symbols,
applyProp,
applyAttr,
elementVoid,
currentPointer,
skipNode,
notifications
} from 'incremental-dom'
import domdiff from 'domdiff'
import { isElement, isIterable, paramCase, SPECT_CLASS } from './util'
const _vnode = Symbol('vnode')
attributes.class = applyAttr
attributes.is = (target, name, value) => {
if (target.setAttribute) applyAttr(target, name, value)
return applyProp(target, name, value)
}
attributes[symbols.default] = applyProp
// render vdom into element
export default function html(el, ...args) {
let content
// html`<...>`
// html(...)
if (!args.length || (Array.isArray(el) && el.raw)) {
content = htm.call(h, el, ...args)
el = document.createDocumentFragment()
}
elementOpen,
elementClose,
text,
attributes,
symbols,
applyProp,
applyAttr,
elementVoid,
currentPointer,
skipNode,
notifications
} from 'incremental-dom'
import { isIterable, paramCase, SPECT_CLASS } from './util'
attributes.class = applyAttr
attributes.is = (target, name, value) => {
if (target.setAttribute) applyAttr(target, name, value)
return applyProp(target, name, value)
}
attributes[symbols.default] = applyProp
notifications.nodesDeleted = function (nodes) {
nodes.forEach((node) => node[_spect] && node[_spect].dispose())
};
const _target = Symbol.for('spect.target')
const _instance = Symbol.for('spect.instance')
const _spect = Symbol.for('spect')
export default function html(...args) {
import tuple from 'immutable-tuple'
import htm from 'htm'
import {
patch,
elementOpen,
elementClose,
text,
attributes,
symbols,
applyProp,
applyAttr
} from 'incremental-dom'
attributes.class = applyAttr
attributes.is = (...args) => (applyAttr(...args), applyProp(...args))
attributes[symbols.default] = applyProp
let html = htm.bind(h)
const aspectsCache = new WeakMap,
depsCache = new WeakMap,
destroyCache = new WeakMap,
observables = new Map,
stateCache = new WeakMap
let fxCount,
currentElement,
currentAspect