svnno****@sourc*****
svnno****@sourc*****
2010年 1月 31日 (日) 21:46:26 JST
Revision: 1612 http://sourceforge.jp/projects/sie/svn/view?view=rev&revision=1612 Author: dhrname Date: 2010-01-31 21:46:26 +0900 (Sun, 31 Jan 2010) Log Message: ----------- initMutationEventメソッドの修正 Modified Paths: -------------- branches/DOM/org/w3c/dom/events.js Modified: branches/DOM/org/w3c/dom/events.js =================================================================== --- branches/DOM/org/w3c/dom/events.js 2010-01-31 12:27:29 UTC (rev 1611) +++ branches/DOM/org/w3c/dom/events.js 2010-01-31 12:46:26 UTC (rev 1612) @@ -136,39 +136,14 @@ }; Document.prototype.dispatchEvent = function( /*Event*/ evt) { this.docuemntElement.dispatch(evt); -} -//以下はDOMで設計されていないことに気をつける -Document.prototype._fireEvent = function(type, bubble, cancel) { //eventの発火 - var evt = this.createEvent(); - evt.initEvent(type,bubble,cancel); - evt.target = this[window.event.srcElement.uniqueID]; - var p = evt.target, ch = [], n = 0; //chはノードリスト - while (!p) { - ch[n] = p; - n++; p = p.parentNode; - } - for (var i=0,chi=ch.length*2-1;i<chi;i++) { - evt.currentTarget = ch[i]; - if (i == ch.length-1) { - evt.eventPhase = 2; - } else if (i > ch.length-1) { - evt.eventPhase = 3; - } - ch[i].dipatchEvent(evt); - } - if (typeof this._updateAfterEvent != "undefined") { - this.updateAfterEvent(); - this._arr = null; - this._arr = []; - } - evt = null; -} -Document.prototype._updateAfterEvent = function() { //event終了時に強制描画 var tarr = this._arr; for (var i=0,tarri=tarr.length;i<tarr;++i) { tarr[i].set(this.w,this.h); } -} + this._arr = null; + this._arr = []; + evt = null; +}; function EventListener(cap,type,listener) { this._cap = cap; this._type = type; this._listener = listener; @@ -190,7 +165,7 @@ if (!evt) { var evt = { ctrlKey:null, shiftKey:null, altKey:null, clientX:null, clientY:null}; } - /*DOMString*/ this.type = ""; + /*DOMString*/ this.type; /*EventTarget*/ this.target; /*EventTarget*/ this.currentTarget = null; /*unsigned short*/ this.eventPhase = Event.CAPTURING_PHASE; @@ -217,7 +192,9 @@ return this; }*/ /*Event*/ Document.prototype.createEvent = function( /*string*/ eventType) { - return new Event(window.event); + var evt = new Event(window.event); + evt.type = eventType; + return evt; }; function UIEvent() { @@ -236,8 +213,8 @@ function MouseEvent(evt) { /*long*/ this.screenX; /*long*/ this.screenY; -/*long*/ this.clientX = false; -/*long*/ this.clientY = false; +/*long*/ this.clientX = 0; +/*long*/ this.clientY = 0; /*boolean*/ this.ctrlKey = false; /*boolean*/ this.shiftKey = false; /*boolean*/ this.altKey = false; @@ -260,6 +237,12 @@ return this; }; /*void*/ MutationEvent.prototype.initMutationEvent = function(/*string*/ typeArg, /*boolean*/ canBubbleArg, /*boolean*/ cancelableArg, /*Node*/ relatedNodeArg, /*string*/ prevValueArg, /*string*/ newValueArg, /*string*/ attrNameArg, /*unsigned short*/ attrChangeArg) { + this.initEvent( typeArg, canBubbleArg, cancelableArg); + this.relatedNode = relatedNodeArg; + this.prevValue = prevValueArg; + this.newValue = newValueArg; + this.attrName = attrNameArg; + this.attrChange = attrChangeArg }; MutationEvent.prototype = new Event(); MutationEvent.constructor = Event;