How to use the incremental-dom.attributes.class function in incremental-dom

To help you get started, we’ve selected a few incremental-dom examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github spectjs / spect / html.js View on Github external
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') {
github spectjs / spect / src / html-idom.js View on Github external
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()
  }
github spectjs / spect / src / html.js View on Github external
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) {
github spectjs / spect / src / min.js View on Github external
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