Can someone please help me understand how to read this retaining tree ( sorry for the text view, I'm unable to insert image due to corporate policies ). The "grid" object should no longer be available but it is being kept alive by the following tree.
grid in system / Context @576113
context in function() @576117
4 in @632133
66 in (code) @261183
code in function() @ 261805
Row in @36853
kg in Window / localhost @2827
Distance of "grid" is 7, kg in Window is 1.
The functions above are from the koGrid library, although slightly modified.
The function referred to by @261805 is declared as window.kg.Row = function(entity, config, selectionService, prevRow) { ... }. This is used as a constructor function and is instantiated using "new window.kg.Row(...)"
The function referred to by @576117 is a function attached to the selectionService instance ("setSelection").
Observations:
@36853 refers to the "kg" object in Window. This is where all the constructor functions are declared ( see below )
The context in function() refers to the closure over the SelectionService constructor function in which grid is the sole argument.
The setSelection function is an anonymous function attached to an instance of SelectionService ( see below ) and is only ever created/declare when executing the SelectionService constructor.
Assumptions
@261805 refers to the Row constuctor function in the kg object, NOT the instance of an individual Row constructed by using new window.kg.Row()
@576117 refers to the anonymous function setSelection
Questions...
What does "66 in (code)" refer to ? I get "not available" if I hover over this.
What does "4 in @632133" refer to ? I also get "not available" if I hover over this.
How did I get from a constructor function definition to an instance context of function setSelection @576117
If entity @261805 is not the constructor definition and is in actuality an instance reference of Row, then what is linking that to window.kg.Row
Changing the order of the lines of code in the Row constructor function then 66 appears to refer to the line of code (which also happens to be the 33th line of code )
"self.selectionService.setSelection(self, self.entity[SELECTED_PROP]);"
Inserting a line immediately above this "moves" 66 in code to 68 in code. Inserting any line of code AFTER this line does not change the value of 66.
Here is a cut down version of the code involved in this tree.
window.kg.Grid = function() {
var self = this;
self.SelectionService = new window.kg.SelectionService(self);
}
window.kg.SelectionService = function(grid) {
var self = this;
self.setSelection = function(rowItem, isSelected) {
...
}
}
window.kg.Row = function( entity, config, selectionService, prevRow ) {
var self = this;
self.selectionService = selectionService;
...
self.selectionService.setSelection( self, self.entity[SELECTED_PROP] );
...
}