How to use the snabbdom/vnode.vnode function in snabbdom

To help you get started, we’ve selected a few snabbdom 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 AlexGalays / kaiju / src / lib / render.js View on Github external
function patchInto(target, node) {
  const targetIsArray = Array.isArray(target)
  const nodeIsArray = Array.isArray(node)

  if (nodeIsArray)
    mapPrimitiveNodes(node)

  // First render inside an Element
  if (target.elm === undefined) {
    patch(
      VNode('dummy', {}, [], undefined, target),
      VNode('dummy', {}, nodeIsArray ? node : [node])
    )

    if (nodeIsArray)
      node.elm = target
  }
  // Update using a previous VNode or VNode[] to patch against
  else {
    if (targetIsArray) {
      patch(
        VNode('dummy', {}, target, undefined, target.elm),
        VNode('dummy', {}, nodeIsArray ? node : [node])
      )
    }
    else {
      patch(target, node)
    }
github AlexGalays / kaiju / src / lib / render.js View on Github external
// First render inside an Element
  if (target.elm === undefined) {
    patch(
      VNode('dummy', {}, [], undefined, target),
      VNode('dummy', {}, nodeIsArray ? node : [node])
    )

    if (nodeIsArray)
      node.elm = target
  }
  // Update using a previous VNode or VNode[] to patch against
  else {
    if (targetIsArray) {
      patch(
        VNode('dummy', {}, target, undefined, target.elm),
        VNode('dummy', {}, nodeIsArray ? node : [node])
      )
    }
    else {
      patch(target, node)
    }

    if (nodeIsArray)
      node.elm = target.elm
  }
}
github AlexGalays / kaiju / src / lib / render.js View on Github external
function patchInto(target, node) {
  const targetIsArray = Array.isArray(target)
  const nodeIsArray = Array.isArray(node)

  if (nodeIsArray)
    mapPrimitiveNodes(node)

  // First render inside an Element
  if (target.elm === undefined) {
    patch(
      VNode('dummy', {}, [], undefined, target),
      VNode('dummy', {}, nodeIsArray ? node : [node])
    )

    if (nodeIsArray)
      node.elm = target
  }
  // Update using a previous VNode or VNode[] to patch against
  else {
    if (targetIsArray) {
      patch(
        VNode('dummy', {}, target, undefined, target.elm),
        VNode('dummy', {}, nodeIsArray ? node : [node])
      )
    }
    else {
      patch(target, node)
github AlexGalays / kaiju / src / lib / render.js View on Github external
// First render inside an Element
  if (target.elm === undefined) {
    patch(
      VNode('dummy', {}, [], undefined, target),
      VNode('dummy', {}, nodeIsArray ? node : [node])
    )

    if (nodeIsArray)
      node.elm = target
  }
  // Update using a previous VNode or VNode[] to patch against
  else {
    if (targetIsArray) {
      patch(
        VNode('dummy', {}, target, undefined, target.elm),
        VNode('dummy', {}, nodeIsArray ? node : [node])
      )
    }
    else {
      patch(target, node)
    }

    if (nodeIsArray)
      node.elm = target.elm
  }
}
github appcues / snabbdom-virtualize / test / nodejs_tests.js View on Github external
it("should convert nodes with children", () => {
            const ul = doc.createElement('ul');
            ul.innerHTML = "<li>One</li><li>Fish</li><li>Two</li><li>Fish</li>";
            expect(virtualizeNodes(ul, opts)).to.deep.equal(
                extendVnode(h('ul', [
                    extendVnode(h('li', [ extendVnode(VNode(undefined, undefined, undefined, 'One'), ul.childNodes[0].firstChild) ]), ul.childNodes[0]),
                    extendVnode(h('li', [ extendVnode(VNode(undefined, undefined, undefined, 'Fish'), ul.childNodes[1].firstChild) ]), ul.childNodes[1]),
                    extendVnode(h('li', [ extendVnode(VNode(undefined, undefined, undefined, 'Two'), ul.childNodes[2].firstChild) ]), ul.childNodes[2]),
                    extendVnode(h('li', [ extendVnode(VNode(undefined, undefined, undefined, 'Fish'), ul.childNodes[3].firstChild) ]), ul.childNodes[3])
                ]), ul)
            );
        });
github appcues / snabbdom-virtualize / test / nodejs_tests.js View on Github external
it("should convert nodes with children", () =&gt; {
            const ul = doc.createElement('ul');
            ul.innerHTML = "<li>One</li><li>Fish</li><li>Two</li><li>Fish</li>";
            expect(virtualizeNodes(ul, opts)).to.deep.equal(
                extendVnode(h('ul', [
                    extendVnode(h('li', [ extendVnode(VNode(undefined, undefined, undefined, 'One'), ul.childNodes[0].firstChild) ]), ul.childNodes[0]),
                    extendVnode(h('li', [ extendVnode(VNode(undefined, undefined, undefined, 'Fish'), ul.childNodes[1].firstChild) ]), ul.childNodes[1]),
                    extendVnode(h('li', [ extendVnode(VNode(undefined, undefined, undefined, 'Two'), ul.childNodes[2].firstChild) ]), ul.childNodes[2]),
                    extendVnode(h('li', [ extendVnode(VNode(undefined, undefined, undefined, 'Fish'), ul.childNodes[3].firstChild) ]), ul.childNodes[3])
                ]), ul)
            );
        });
github AlexGalays / kaiju / src / lib / render.js View on Github external
const emptyNode = () => VNode('!', {}, [], undefined, undefined)