GithubHelp home page GithubHelp logo

resonance-cascade / cache-component Goto Github PK

View Code? Open in Web Editor NEW
16.0 16.0 2.0 195 KB

DEPRECATED: Use nanocomponent. Will continue to operate as normal

Home Page: https://github.com/choojs/nanocomponent

License: MIT License

JavaScript 100.00%
bel choo

cache-component's People

Contributors

bcomnes avatar greenkeeper[bot] avatar greenkeeperio-bot avatar joshgillies avatar reminyborg avatar roobie avatar ungoldman avatar xz64 avatar yoshuawuyts avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

cache-component's Issues

Maybe don't morph internally

Since we use an ID system to match nodes now, maybe we can go back to not morphing internally. Or maybe we do, since its more contained that way.

Update docs

  • Add better examples,
  • Slim down the docs
  • Document some of the tricks you can do with this
  • Have an ES6 class example

Elements with mutating child-nodes are not cached

At the moment, due to this line, any element with mutating children is never cached. Actually what happens is the original element is cached, but the proxy never gets replaced with the cached element, so after one change the cached element drops permanently from the DOM.

This is because mutating a child element changes the identity of the element, so el === self._element will be false.

This is being discussed over at nanomorph too.

I propose that the simplest solution is to check whether the element has an id attribute during proxy creation. If it does, copy the id to the proxy, then use id comparison instead of element equality:

CacheElement.prototype._createProxy = function () {
  var el = this._hasWindow ? document.createElement('div') : this._element
  el.setAttribute('data-cache-component', '')
  if (this._element && this._element.id) {
    el.setAttribute('id', this._element.id)
  }
  var self = this
  el.isSameNode = function (el) {
    return self._element.id ? el.id === self._element.id : el === self._element
  }
  return el
}

PR incoming...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.