in asdoc/XML.js [2464:2506]
XML.prototype.replaceChildAt = function(idx, v) {
var /** @type {number} */ len = 0;
//var /** @type {number} */ len = 0;
var /** @type {string} */ ref = this.getNodeRef();
if (ref == XML.TEXT || ref == XML.COMMENT || ref == XML.PROCESSING_INSTRUCTION || ref == XML.ATTRIBUTE)
return;
len = this.childrenLength();
if (idx > len)
idx = len;
this.XML_getChildren();
if (org.apache.royale.utils.Language.is(v, XML) && v.getNodeRef() != XML.ATTRIBUTE) {
if (v.getNodeRef() == XML.ELEMENT && (v == this || this.XML_isAncestor(v)))
throw new TypeError("cannot assign parent xml as child");
v.setParent(this);
if (this._children[idx])
this.removeChild(this._children[idx]);
this.XML_insertChildAt(v, idx);
} else if (org.apache.royale.utils.Language.is(v, XMLList)) {
len = v.length();
if (this._children[idx])
this._children[idx].XML__parent = null;
if (len) {
v[0].setParent(this);
this._children[idx] = v[0];
var /** @type {number} */ listIdx = 1;
var /** @type {XML} */ chld = v[0];
while (listIdx < len) {
chld = v[listIdx];
this.XML_insertChildAt(chld, (idx + listIdx) >> 0);
listIdx++;
}
} else {
this._children.splice(idx, 1);
}
} else {
chld = new XML();
chld.setValue(v + '');
chld.setParent(this);
if (this._children[idx] != null)
this._children[idx].setParent(null);
this._children[idx] = chld;
}
};