Item#setName: Check for Item#_parent to avoid errors in removed items and top level groups. Fixes #76

This commit is contained in:
Jonathan Puckey 2012-03-01 16:43:05 +01:00
parent 55a795c285
commit a343724094

View file

@ -209,7 +209,7 @@ var Item = this.Item = Base.extend(Callback, /** @lends Item# */{
if (this._name)
this._removeFromNamed();
this._name = name || undefined;
if (name) {
if (name && this._parent) {
var children = this._parent._children,
namedChildren = this._parent._namedChildren;
(namedChildren[name] = namedChildren[name] || []).push(this);