Skeletor
Skeletor is a Backbone fork.
Its goal is to modernize and componentize Backbone.
Original Backbone Views can't be rendered in a nested and declarative way,
similarly to how components are rendered in React and other frameworks.
We can solve this by making Views web components. Check out the ElementView
class, which does this.
Why bother?
The goal of this fork is to allow the Converse team to gradually update the Converse
XMPP webchat client to use web components (using LitElement)
without requiring us to put everything on hold in order to do a massive rewrite.
The end-goal is to not have any Backbone/Skeletor Views at all, only LitElement components.
We can cheat a little by letting the existing Views also be web components
(more accurately, "custom elements"), this allows us to declaratively render the
UI, while we're progressively getting rid of the views.
Sekeletor adds the following changes to Backbone
- Removes the dependency on jQuery
- Instead of the
render
method Views can have a toHTML
method which must return a lit-html TemplateResult
. - Replaces underscore with lodash
- Imports lodash methods individually to allow for tree-shaking
- Uses the native browser API instead of lodash whereever possible
- Drops support for older browsers (including IE) and uses ES6+ language features
- Splits models, views and collections into separate modules
- Adds the possibility to returns promises for asynchronous operations
- Adds a new
ElementView
class, which is a like a Backbone View, but doubles
as an instance of HTMLElement and can be used to register a custom element or
web-component.
Backwards incompatible changes
- Collection.prototype.forEach no longer returns the items being iterated over.
If you need that, use
map
instead. - The
chain
method on Models has been removed. - The
inject
, foldl
and foldr
methods on Collections has been removed. You can use reduce
instead. - Removed the
sample
, take
, tail
and initial
method on Collections. - Removed the
without
, reject
and select
methods on Collections, use filter
.
Changes due to using Lodash instead of Underscore
- Use
drop
instead of rest
. indexBy
is called keyBy
- Use
invokeMap
for collections instead of invoke
. - Use
includes
instead of contains
- The
partition
and invokeMap
methods have been removed.