Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
460 views
in Technique[技术] by (71.8m points)

javascript - 虚拟DOM到底存储在哪里?(Where exactly the Virtual DOM is stored?)

I'm torturing myself for hours now and can't find an answer.

(我正在折磨自己几个小时,找不到答案。)

Where exactly, under what object/key, the React data are located?

(React数据到底位于哪个对象/键的哪个位置?)

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.

(我找到了一个对象ReactRoot ,该对象似乎存储了有关组件的所有信息,但是我不知道它在窗口对象中的位置(我猜吗?)。)

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

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

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构造函数,则chrome将在$0chrome中为$ 0 )下创建对其的引用。)

EDIT

(编辑)

Is it possible that ReactRoot is declared in a way that makes it inaccessible for other objects?

(是否有可能以其他对象无法访问的方式声明ReactRoot?)

How is this possible in js?

(这在js中怎么可能?)

React isn't getting any special treatment from the browsers, is he?

(React没有从浏览器中获得任何特殊待遇,是吗?)

  ask by platinum_ar translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

There is a document explaining the DOM Level 1 fundamental methods.

(有一份文档说明了DOM Level 1基本方法。)

See also the DOM Level 1 Core specification from the W3C .

(另请参见W3C中DOM级别1核心规范 。)

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.

(但是其他所有东西只是对象的实例,即虚拟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");

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...