/documentation/appframework/$.cleanUpContent.md
Markdown | 61 lines | 43 code | 18 blank | 0 comment | 0 complexity | eedd97c6c142aa9172bd6e757f55db4f MD5 | raw file
- #$.cleanUpContent(node,itself,kill)
- ```
- Function to clean up node content to prevent memory leaks
-
- ```
- ##Example
- ```
- $.cleanUpContent(node,itself,kill)
-
- ```
- ##Parameters
- ```
- node HTMLNode
- kill Bool
- Kill bool
- ```
- ##Returns
- ```
- undefined
- ```
- ##Detail
- $.cleanUpContent(node,[itself],[kill]) traverses through the dom and tries to de-regster any event listeners to prevent memory leaks.
- This is called internally by $().html() and $().empty(). It does slow down those operations, but the gain is worth it.
- Below is the code for $().html() to show how we use it
- ```
- html: function (html, cleanup) {
- if (this.length === 0)
- return this;
- if (html ===nundefined)
- return this[0].innerHTML;
- for (var i = 0; i < this.length; i++) {
- if (cleanup !== false)
- $.cleanUpContent(this[i], false, true);
- if(isWin8)
- {
- MSApp.execUnsafeLocalFunction(function(){
- this[i].innerHTML=html;
- });
- }
- else
- this[i].innerHTML = html;
- }
- return this;
- },
- ```