How to use the incremental-dom.patch 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 eliot-akira / idom / src / core / render.js View on Github external
if ( typeof fn === 'function' ) {

    el.renderFn = fn

  // Previously defined
  } else if ( el.renderFn ) {

    // Apply new attributes to render function
    // Empty string to prevent undefined
    el.renderFn = el.renderFn( fn || '' )

  // No render function
  } else return

  patch( el, el.renderFn )

  // The rendered element
  return el.firstChild
}
github skatejs / skatejs / test / unit / vdom / incremental-dom.js View on Github external
      it(desc, () => IncrementalDOM.patch(fixture(), func));
    }
github yhatt / markdown-it-incremental-dom / test / markdown-it-incremental-dom.js View on Github external
it('parses HTML string by htmlparser2', () => {
            const func = md({
              incrementalizeDefaultRules: false,
            }).renderInlineToIncrementalDOM(mdString)

            IncrementalDOM.patch(document.body, func)
            expect(spy).toHaveBeenCalledWith(expectedHTML)
          })
        })
github yhatt / markdown-it-incremental-dom / test / renderer.js View on Github external
const renderWithIncrementalDOM = (func, args) => {
      IncrementalDOM.patch(document.body, func(...args))
      return document.body.innerHTML
    }
github yhatt / markdown-it-incremental-dom / test / markdown-it-incremental-dom.js View on Github external
const instance = md()
      const { options } = instance
      const tokens = instance.parse('# test')

      instance.renderer.rules.heading_open = () => '['
      instance.renderer.rules.heading_close = () => ']'

      const rendererOne = instance.IncrementalDOMRenderer
      IncrementalDOM.patch(document.body, rendererOne.render(tokens, options))
      expect(document.body.innerHTML).toBe('[test]')

      instance.renderer.rules.heading_open = () => '^'
      instance.renderer.rules.heading_close = () => '$'

      const rendererTwo = instance.IncrementalDOMRenderer
      IncrementalDOM.patch(document.body, rendererTwo.render(tokens, options))
      expect(document.body.innerHTML).toBe('^test$')
    })
  })
github ferrugemjs / library / src / core / component-factory.ts View on Github external
proxy_inst.$draw = function({key_id,is}:any){
          //console.log(key_id,is,this);
          patch(
            document.getElementById(key_id),
            this.$render.bind(this,{key_id, is, loaded:true}),
            this
          )
        }
        inst_watched[key_id] = {$loaded: false, inst: proxy_inst, $is:is, $propsAfterAttached:propsAfterAttached};
github davidjamesstone / noide / client / js / tree / index.js View on Github external
function render () {
    var tree = makeTree(fsos)
    patch(el, update, tree)
  }
github eliot-akira / idom / src / index.js View on Github external
element.render = (fn, el) => (patch(el, fn))
github node-organic / organic-oval / engines / incremental-dom.js View on Github external
return function () {
    let templateBuilderFn = component.template()
    if (INCREMENTAL_RENDERING) {
      templateBuilderFn()
    } else {
      INCREMENTAL_RENDERING = true
      IncrementalDOM.patch(component, templateBuilderFn)
      INCREMENTAL_RENDERING = false
    }
  }
}
github skatejs / kickflip / src / render.js View on Github external
return function (elem) {
    if (!elem.shadowRoot) {
      elem.attachShadow({ mode: 'open' });
    }
    patch(elem.shadowRoot, internalRenderer, elem);
  };
}