虚拟DOM到底存储在哪里? [英] Where exactly the Virtual DOM is stored?

查看:395
本文介绍了虚拟DOM到底存储在哪里?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在折磨自己几个小时,找不到答案. React数据到底位于哪个对象/键下的哪个位置?我发现一个对象ReactRoot似乎存储了有关组件的所有信息,但是我不知道它在窗口对象中的位置(我猜是吗?).

I'm torturing myself for hours now and can't find an answer. Where exactly, under what object/key, the React data are located? I found an object ReactRoot that seems to store all the information about components, but I have no idea where it sits in the window (I guess?) object.

它必须在窗口对象下的某个地方,对吗?

It has to be somewhere under the window object, right?

如果拍摄内存快照并从列表中选择ReactRoot构造函数,则chrome将在$0下创建对其的引用(

If you take a memory snapshot and select the ReactRoot constructor from the list, chrome will create a reference to it under $0 ($0 in chrome).

编辑

ReactRoot是否有可能以其他对象无法访问的方式声明?这在js中怎么可能? React没有从浏览器中得到任何特殊待遇,是吗?

Is it possible that ReactRoot is declared in a way that makes it inaccessible for other objects? How is this possible in js? React isn't getting any special treatment from the browsers, is he?

推荐答案

有一个文档说明 DOM级别基本方法. 另请参见.

There is a document explaining the DOM Level 1 fundamental methods. See also the DOM Level 1 Core specification from the W3C.

创建元素时,会创建该元素的新实例,但未渲染.直到将它们包含在DOM树中.

When you create an element, a new instance of the element were created but not rendered. Not until you include them into the DOM tree.

浏览器将仅在文档正文中呈现元素.但是其他所有东西只是对象的实例,即虚拟DOM.

Browser will only render elements within the document body. But everything else is just an instance of an object, the virtual DOM.

// create a new Text node for the second paragraph
    var newText = document.createTextNode("This is the second paragraph.");
    // create a new Element to be the second paragraph
    var newElement = document.createElement("P");

这篇关于虚拟DOM到底存储在哪里?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆