Giter VIP home page Giter VIP logo

vidom's Introduction

vidom

Build Status NPM Version Dependencies NPM Downloads

Vidom is just a library to build UI. It's highly inspired from React and based on the same ideas. Its main goal is to provide as fast as possible lightweight implementation with API similar to React.

Main features

  • Fast virtual DOM builder and patcher under the hood
  • Update batching and synchronization with browsers rendering lifecycle by default
  • Fast server-side rendering with ability to reuse existing DOM in the browsers also known as isomorphism
  • Easy and clear way to subscribe to DOM Events
  • API to build your own high-level components
  • Namespaces support (e.g., SVG, MathML)
  • Ability to render multiple components without unwanted DOM wrappers
  • No extra markup in the result HTML
  • JSX support via babel plugin
  • TypeScript support
  • Small footprint, 9KB after gzip
  • Zero dependencies

Benchmarks

                   mean time ops/sec
  vidom v0.9.23    0.505ms   1981
  inferno v3.10.1  0.511ms   1958
  preact v8.2.6    1.414ms   707
  react v16.0.0    1.479ms   676
  vue v2.5.2       8.883ms   113

Playground

Try live playground to play with Vidom in your browser.

Documentation

Tools

  • Vidom inspector developer tool which helps debug vidom-based applications

Addons

Examples

Thanks

  • cdnjs for library is avalaible on CDN.

vidom's People

Contributors

dfilatov avatar dmikis avatar persidskiy avatar thysultan avatar veged avatar

Stargazers

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

Watchers

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

vidom's Issues

[Q] onUnmount() behavior

Hi! README.md contains:

onUnmount()
The callback which will be invoked before a component is unmounted from DOM.

OTOH, let's look at the fragment in createComponent.js:

function unmountComponent() {
    this._isMounted = false;
    this._rootNode.unmount();
    this.onUnmount();
}

So, I'm wonder what is the onUnmount() behavior? Before? After?

And at the case intention is to call it before umounting (I hope :)), I guess it's signature must include a callback (common names for it are done or next) to permit async operations, say:

function onUnmount(el, next) {
  fetch('url').then(resp => {
    use(resp);
    next(); // real unmounting is triggered by this call!
}

Please, clarify a little :)

css styles are missing

There are no features for setting css styles as plain text, object or as a stylesheet.

quick fix solution for removeEventlisteners

It just stroke my mind. Have a look at this:
https://github.com/dfilatov/vidom/blob/master/lib/nodes/TagNode.js#L122

You are treating this as attributes now as I understand. So you wouldn't need this line anymore. When you do a diffing / patching and updates the attributes, you should also update the events there. And add / remove directly.

Got it? It will also give you performance gains in the iteration loop.

Further. I don't think this code snippet are needed anymore? https://github.com/dfilatov/vidom/blob/master/lib/nodes/TagNode.js#L25

dirty checking?

I can't find any feature for dirty checking, and force updates? Is there any?
If you have a ul tag with 4 li child nodes, how are you going to update only the 3rd li child node?

it's own property object?

REACT have a lot of back and forth issues regarding their props and attributes. To closely follow the DOM standards, shouldn't it be an idea to add a props object same as for attributes?
Due to the DOM standards, there is no mixture of them both, they are separeated.

[Q] is update() synchronous?

Hi! Documentation says:

update()
Forces to schedule component update.

Usually the word "schedule" is used to denote asynchronous nature. What does it mean at the vidom context?

Can't run benchmark with the new changes

Hi. I just saw your new changes, and wanted to benchmark it. But I ran into a couple of issues.

When I run the benchmark with current setup, removeChild() second argument are null

Seems like for text nodes that the `_domNode' are not set? In console.log too it show me a null.

Maybe you have to adjust the benchmark setup?

properties names inconsistency

Hi! At the README.md end we get:

    return vidom.createNode('div')
        .attrs({ className : 'input' })
        .children(vidom.createNode('input').attrs({ type : 'text', className : 'input__control' }));

As far as to define CSS class className is using, it's natural to conclude DOM node properties are supposed. On the other hand, the function is named as attrs. I guess, here we get naming inconsistency, as far as attributes is associated with HTML attributes rather than with DOM node properties.

Probably, the best way is to use both (with some denoted contract who win, say, the last in call chain), that is attributes and properties functions named as attrs and props respectively (as, say, is done in Trackira), and for now just to rename attrs to props.

prefer synchronous design

Hi!

Except for update() I have found asynchronous mode can be used on component unmounting. Probably, I have missed other places, but these two ones are here at least :)

I guess, rejecting an intention to keep all library operation synchronous is extremely strong and important decision. Current not-trivial SPA application can have very asynchronous operation mode, and adding additional asynchronous dimension on the presentation layer can significantly complicate overall design.

Possible complication concerns update() method especially: the method can be used extremely wide, and it is impossible to predict all those places where update() call can take place :)

I haven't found solid benchmark results proving the RAF is really unconditional winner. If at some use cases it is a winner, overcomplicating will (or can) neglect any vague profit.

So, I would suggest to eliminate any asynchronous modes from the library.

Of course, it may be the case I have missed some outstanding deep and wide researches proving RAF is a must have.

math tag issues

There are no namespace for the math tag. And how are you going to support it?

svg tag issues

if you create a svg element with a circle as it child, it will not inherit from it's parent and get same namespace. So it will not be visible.

Rendring svg element inside a div or span tag, and it will not be visible.

There are no SVG namespace either.

Implement reference system for components

vidom.createComponent({
    onRender : function() {
        return vidom.createNode('div').children(vidom.createNode('input').ref('control'));
    },

    onMount : function() {
        this.getRef('control').focus();
    }
});

Focus lost

Let say you have created a virtual DOM tree, and want to trigger a event on a particular node in the tree.

How you do it?

Example "change" should be "triggered" each time you e.g. click / change it. And I can't find any use of document.activeElement, so the focus will be lost if you have 3 select and jumping from one to one?

select and select multiple

select and select multiple seems to have issues. Values not set correctly or loaded corectly during pageload. There are some IE issues here too that you are not aware of.

Seems also to be an issue with select in a select group with multiple children.

Are this going to be fixed? And selectedIndex?

[WRONG] poor performance

Hi. Notice that this lib all over have a poor performance. Use of a constructor are terrible slow. Without RAF or setTimeOut the render take 15ms. Are this going to be fixed?

Too much overhead.

Use of 'this' keyword everywhere are also a huge performance killer. And so are use of 'new' keyword too.

can't set className

Hi. I can't set className at all, only "class" as a property. Sometimes I would ned to set that.

in vanila js you can do:

node.className =

I can't get this to work, only class.

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.