*/
/*Node*/ insertBefore : function( /*Node*/ n, ref) {
var tp = this.parentNode,
+ np = n.parentNode,
rp;
if (tp) {
while (!tp) { //先祖をたどっていく
if (this.ownerDocument !== n.ownerDocument) { //所属Documentの生成元が違うならば
throw (new DOMException(DOMException.WRONG_DOCUMENT_ERR));
}
- if (n.parentNode === this) { //入力した要素が子要素ならば
+ if (np === this) { //入力した要素が子要素ならば
this.removeChild(n);
}
+ if (np) {
+ (n === np.firstChild) && (np.firstChild = n.nextSibling);
+ (n === np.lastChild ) && (np.lastChild = n.previousSibling);
+ }
if (!ref) { //参照要素がNULLの場合、要素を追加する(appendChildと同じ効果)
n._num = this.childNodes.length;
this.childNodes[n._num] = n;
this.firstChild = this.childNodes[0];
this.lastChild = this.childNodes[this.childNodes.length-1];
n.parentNode = this;
- tp = ref = rp = void 0;
+ tp = np = ref = rp = void 0;
return n;
},
/*replaceChildメソッド
/*Node*/ Node.prototype.insertBefore = function( /*Node*/ n, ref) {
var tp = this.parentNode,
+ np = n.parentNode,
rp, evt,
te = this,
s, descend, di;
if (this.ownerDocument !== n.ownerDocument) { //所属Documentの生成元が違うならば
throw (new DOMException(DOMException.WRONG_DOCUMENT_ERR));
}
- if (n.parentNode === this) { //入力した要素が子要素ならば
+ if (np === this) { //入力した要素が子要素ならば
this.removeChild(n);
}
- if (n.parentNode) {
- (n === n.parentNode.firstChild) && (n.parentNode.firstChild = n.nextSibling);
- (n === n.parentNode.lastChild ) && (n.parentNode.lastChild = n.previousSibling);
+ if (np) {
+ (n === np.firstChild) && (np.firstChild = n.nextSibling);
+ (n === np.lastChild ) && (np.lastChild = n.previousSibling);
}
if (!ref) { //参照要素がNULLの場合、要素を追加する(appendChildと同じ効果)
n._num = this.childNodes.length;
}
}
evt = descend = void 0;
- tp = rp = te = s = di = void 0;
+ tp = np = rp = te = s = di = void 0;
return n;
};