svnno****@sourc*****
svnno****@sourc*****
2010年 2月 23日 (火) 22:36:14 JST
Revision: 1673 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1673 Author: dhrname Date: 2010-02-23 22:36:14 +0900 (Tue, 23 Feb 2010) Log Message: ----------- DOMNodeRemovedFromDocumentイベントのサポート Modified Paths: -------------- branches/ufltima/dom/events.js Modified: branches/ufltima/dom/events.js =================================================================== --- branches/ufltima/dom/events.js 2010-02-23 13:35:28 UTC (rev 1672) +++ branches/ufltima/dom/events.js 2010-02-23 13:36:14 UTC (rev 1673) @@ -202,7 +202,7 @@ function UIEvent() { /*views::AbstractView*/ this.view; -/*long*/ this.detail = 0; +/*long*/ this.detail = 0; return this; }; @@ -216,12 +216,12 @@ function MouseEvent(evt) { /*long*/ this.screenX; /*long*/ this.screenY; -/*long*/ this.clientX = 0; -/*long*/ this.clientY = 0; -/*boolean*/ this.ctrlKey = false; +/*long*/ this.clientX = 0; +/*long*/ this.clientY = 0; +/*boolean*/ this.ctrlKey = false; /*boolean*/ this.shiftKey = false; -/*boolean*/ this.altKey = false; -/*boolean*/ this.metaKey = false; +/*boolean*/ this.altKey = false; +/*boolean*/ this.metaKey = false; /*unsigned short*/ this.button; /*EventTarget*/ this.relatedTarget; return this; @@ -329,15 +329,15 @@ */ evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null); n.dispatchEvent(evt); - var descendantElements = this.getElementsByTagNameNS("*", "*"); //全子孫要素を取得 - for (var i=0,dli=descendantElements.length;i<dli;++i) { - var di = descendantElements[i]; + var descend = this.getElementsByTagNameNS("*", "*"); //全子孫要素を取得 + for (var i=0,dli=descend.length;i<dli;++i) { + var di = descend[i]; evt.target = di; evt.initMutationEvent("DOMNodeInsertedIntoDocument", false, false, null, null, null, null, null); di.dispatchEvent(evt); di = null; } - evt = descendantElements = null; + evt = descend = null; /*ここまで追加*/ return n; }; @@ -349,9 +349,23 @@ /*ここから*/ var evt = this.ownerDocument.createEvent("MutationEvents"); evt.target = ele; + /*以下のDOMNodeRemovedFromDocumentイベントは、間接的、あるいは直接ノードが + *除去されたときに発火する。間接的な除去とは、サブツリーをいっぺんに除去する場合など。 + *このイベントは浮上しないことに注意を要する + */ + evt.initMutationEvent("DOMNodeRemovedFromDocument", false, false, null, null, null, null, null); + n.dispatchEvent(evt); + var descend = this.getElementsByTagNameNS("*", "*"); //全子孫要素を取得 + for (var i=0,dli=descend.length;i<dli;++i) { + var di = descend[i]; + evt.target = di; + evt.initMutationEvent("DOMNodeRemovedFromDocument", false, false, null, null, null, null, null); + di.dispatchEvent(evt); + di = null; + } evt.initMutationEvent("DOMNodeRemoved", true, false, this, null, null, null, null); ele.dispatchEvent(evt); - evt = null; + evt = descend = null; /*ここまで追加*/ if (ele.parentNode === this) { this.childNodes.splice(ele._num,1); //Arrayのspliceを利用して、リストからeleノードを排除