Skip to content

Commit 66fd40f

Browse files
committed
[manual] Explain the way fromTextArea can leak memory
Issue codemirror#3938
1 parent be36e3e commit 66fd40f

File tree

1 file changed

+24
-21
lines changed

1 file changed

+24
-21
lines changed

doc/manual.html

Lines changed: 24 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
<!doctype html>
1+
<!doctype html>
22

33
<title>CodeMirror: User Manual</title>
44
<meta charset="utf-8"/>
@@ -2064,26 +2064,29 @@ <h3 id="api_static">Static properties</h3>
20642064
else (usually one) for dev snapshots.</dd>
20652065

20662066
<dt id="fromTextArea"><code><strong>CodeMirror.fromTextArea</strong>(textArea: TextAreaElement, ?config: object)</code></dt>
2067-
<dd>
2068-
The method provides another way to initialize an editor. It
2069-
takes a textarea DOM node as first argument and an optional
2070-
configuration object as second. It will replace the textarea
2071-
with a CodeMirror instance, and wire up the form of that
2072-
textarea (if any) to make sure the editor contents are put
2073-
into the textarea when the form is submitted. The text in the
2074-
textarea will provide the content for the editor. A CodeMirror
2075-
instance created this way has three additional methods:
2076-
<dl>
2077-
<dt id="save"><code><strong>cm.save</strong>()</code></dt>
2078-
<dd>Copy the content of the editor into the textarea.</dd>
2079-
2080-
<dt id="toTextArea"><code><strong>cm.toTextArea</strong>()</code></dt>
2081-
<dd>Remove the editor, and restore the original textarea (with
2082-
the editor's current content).</dd>
2083-
2084-
<dt id="getTextArea"><code><strong>cm.getTextArea</strong>() → TextAreaElement</code></dt>
2085-
<dd>Returns the textarea that the instance was based on.</dd>
2086-
</dl>
2067+
<dd>This method provides another way to initialize an editor. It
2068+
takes a textarea DOM node as first argument and an optional
2069+
configuration object as second. It will replace the textarea
2070+
with a CodeMirror instance, and wire up the form of that
2071+
textarea (if any) to make sure the editor contents are put into
2072+
the textarea when the form is submitted. The text in the
2073+
textarea will provide the content for the editor. A CodeMirror
2074+
instance created this way has three additional methods:
2075+
<dl>
2076+
<dt id="save"><code><strong>cm.save</strong>()</code></dt>
2077+
<dd>Copy the content of the editor into the textarea.</dd>
2078+
2079+
<dt id="toTextArea"><code><strong>cm.toTextArea</strong>()</code></dt>
2080+
<dd>Remove the editor, and restore the original textarea (with
2081+
the editor's current content). If you dynamically create and
2082+
destroy editors made with `fromTextArea`, without destroying
2083+
the form they are part of, you should make sure to call
2084+
`toTextArea` to remove the editor, or its `"submit"` handler
2085+
on the form will cause a memory leak.</dd>
2086+
2087+
<dt id="getTextArea"><code><strong>cm.getTextArea</strong>() → TextAreaElement</code></dt>
2088+
<dd>Returns the textarea that the instance was based on.</dd>
2089+
</dl>
20872090
</dd>
20882091

20892092
<dt id="defaults"><code><strong>CodeMirror.defaults</strong>: object</code></dt>

0 commit comments

Comments
 (0)