resonance-cascade / cache-component Goto Github PK
View Code? Open in Web Editor NEWDEPRECATED: Use nanocomponent. Will continue to operate as normal
Home Page: https://github.com/choojs/nanocomponent
License: MIT License
DEPRECATED: Use nanocomponent. Will continue to operate as normal
Home Page: https://github.com/choojs/nanocomponent
License: MIT License
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.
...but only after we land choojs/nanocomponent#38 in beta at least.
Testing dom nodes in node doesn't work well.
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...
They are all set to cahce-element still.
How the hell did I update the name CacheElement
?
If you have two instances of the same component, and try to morph one into the other, you lose the correct internal reference to the real DOM node inside of the component instance on _element. The work around here is to correctly ID using a unique instance ID.
Instance clobbering bug:
https://gist.github.com/bcomnes/fa4fa3a83807b4189356699c17207a0b
I think I solved it in an incoming PR.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.