motorcyclejs / dom

The standard DOM driver for motorcycle.js
MIT License
20 stars 2 forks source link

feat(dom): full rewrite #108

Closed TylorS closed 7 years ago

TylorS commented 7 years ago

The state of the current driver has been very fragile and very difficult to add bug fixes and features for quite some time due to code rot. This introduces a brand new implementation with some design changes and brings in a fork of snabbdom.

Snabbdom is being forked and maintained inside of this driver as a means for fixing bugs and adding features as fast as needed. Already there has been a small (BREAKING) change to the shape of a VNode in order to drastically reduce the scenarios where it is needed to recreate DOM nodes when only a className or ID has been changed.

// before
{
  sel: string,
  data: VNodeData,
  children: VNodeChildren,
  text: string,
  key: string | number,
  elm: Element
}

// now
{
  tagName: string,
  className: string,
  id: string,
  data: VNodeData,
  children: VNodeChildren,
  text: string,
  key: string | number,
  elm: Element
}

Another Snabbdom related change, is a module hooks are now called with a this value of the module as a whole. This allows for modules like IsolateModule to avoid hacks like createModule that captures this as a variable.

Event.currentTarget will no longer be mutated, as this is not something the DOM would actualy do itself.

Going forward I would like to further optimize the virtual-dom implementation for our specific use case and to reimplement an HTML driver.


Things that still need doing

TylorS commented 7 years ago

Documentation has been added