Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

cache-element

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cache-element

Memoize a bel element

  • 3.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
17
increased by142.86%
Maintainers
1
Weekly downloads
 
Created
Source

cache-element stability

npm version build status downloads js-standard-style

Cache an HTML element that's used in DOM diffing algorithms that respect element.isSameNode().

Usage

var cache = require('cache-element')
var html = require('bel')

var nav = cache(function () {
  return html`
    <nav>
      <div>All content</div>
      <div>In here</div>
      <div>Is static</div>
      <div>And doesn't need to be diffed</div>
      <div>On every render</div>
    </nav>
  `
})

document.body.appendChild(nav.render())

API

element = cache(render)

Create a new instance of cache-element. Takes a render function that is called when element.render() is called and a prior call doesn't have a node mounted on the DOM.

element.render()

Render the element to append it on the DOM. As long as the Node is on the DOM, subsequent calls to element.render() will return an empty node that has a .isSameNode() method on it so diffing algorithms that respect this property will skip diffing this node.

Installation

$ npm install cache-element

See Also

License

MIT

Keywords

FAQs

Package last updated on 09 Apr 2017

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc