How's Virtual DOM implementation is different than createDocumentFragment() if no state is observed?

前端 未结 2 1178
盖世英雄少女心
盖世英雄少女心 2021-02-08 05:11

Virtual DOM is a light weight copy of DOM, maintained / cached locally before inserting it into actual DOM. We can change it as we want and then save to our real DOM tree. It us

2条回答
  •  -上瘾入骨i
    2021-02-08 05:21

    The simplest answer is that NodeJS does(/will) not have document.createDocumentFragment, nor document.createElement or any such thing.

    The point of VirtualDOM is to allow for not only large-scale edits to systems where DOM will later be injected, but also to allow for any edits in an environment where the DOM just plain does not exist.

    This is the largest difference between practical application of DocumentFragments and VirtualDOM.

    Added benefits in terms of specific instances of DOM virtualization would be that certain view libraries (React, say) make dealing with these things quite simple, compared to manual insertion into fragments and their children.

提交回复
热议问题