wavesoft / dot-dom

.dom is a tiny (512 byte) template engine that uses virtual DOM and some of react principles
Apache License 2.0
806 stars 53 forks source link

Release 0.3.1 #56

Closed wavesoft closed 4 years ago

wavesoft commented 4 years ago

This PR is WIP for merging the 0.3.1 development branch.

πŸ—‘ Removed features

In order to maintain the 512 byte constraint, some features had to be sacrificed. So we picked the ones with the smallest impact.

✨ New Features

πŸ”Œ Plug-ins

Starting from this version, I have started to introduce plug-ins. That being snippets that can be included aside of the main library that enhance the base functionality, or provide some sort of compatibility layer with other libraries.

Keyed Plugin

The keyed plugin, enables keyed updates in a similar manner to React, or other VDom libraries. This means updating only objects whose key matches the key property.

To use this plug-in, just source the dist/plugin-keyed.min.js and install it where you need it like so:

function Container(props, state) {
  const {components} = props;
  // The function `K` accepts the component state and an array of components that
  // contain the `key` property, and returns the same array of components, with their
  // state correctly manipulated.
  return H("div", K(state, components));
}

Note that if you are only interested into maintaining the state when re-ordering stateful components you don't need this plugin.