This is the Tree constructor. It is intended to be used
internally, and so it returns a mutable object that must be
frozen before it’s returned. For the sake of IE8, and all other
environments that don’t support Object.definePropert(y|ies),
the nasty bit of try/catch here allows those environments to
work without guaranteed immutability.
Tree = function (defaults, obj, inflateMethod, nextNodeId) {
this.defaults = defaults;
var __id, __nextNodeId, __root;
__id = _.uniqueId();
__nextNodeId = nextNodeId || 0;
try {
Object.defineProperties(this, {
'__id': {
value: __id,
writable: true,
enumerable: false,
configurable: false
},
'__nextNodeId': {
value: __nextNodeId,
writable: true,
enumerable: false,
configurable: false
},
'__batch': {
value: 0,
writable: true,
enumerable: false,
configurable: false
}
});
} catch (e) {
this.__id = __id;
this.__nextNodeId = __nextNodeId;
}
if (!!obj && !!inflateMethod) {
__root = Tree.inflate(this, obj, inflateMethod);
} else {
__root = new Node(this);
}
try {
Object.defineProperties(this, {
'__root': {
writable: true,
enumerable: false,
configurable: false,
value: __root
}
});
} catch (e) {
this.__root = __root;
}
};