>From 7efbfa49404222d6c7614385a02f9b7c8057a796 Mon Sep 17 00:00:00 2001 From: Kevin Carhart Date: Mon, 4 Sep 2017 22:19:41 -0700 Subject: [PATCH] Flesh out a few things in the DOM. Add the Event object and pump it in to the addEventHandler and attachEvent. Turn s into a local variable in getComputedStyle to avoid collisions --- src/startwindow.js | 28 ++++++++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) diff --git a/src/startwindow.js b/src/startwindow.js index 9dcdd77..e246600 100644 --- a/src/startwindow.js +++ b/src/startwindow.js @@ -773,6 +773,7 @@ Document = function(){} CSSStyleDeclaration = function(){ this.element = null; this.style = this; + this.attributes = new Array; }; CSSStyleDeclaration.prototype.getPropertyValue = function(p) { @@ -787,7 +788,7 @@ document.style.bgcolor = "white"; getComputedStyle = function(e,pe) { // disregarding pseudoelements for now -s = new CSSStyleDeclaration; +var s = new CSSStyleDeclaration; s.element = e; // This is a rather inefficient use of cssApply, but it is hardly ever called. cssApply(e, s); @@ -1122,6 +1123,23 @@ c.nodeType = 8; return c; } +Event = function(options){ + // event state is kept read-only by forcing + // a new object for each event. This may not + // be appropriate in the long run and we'll + // have to decide if we simply dont adhere to + // the read-only restriction of the specification + this._bubbles = true; + this._cancelable = true; + this._cancelled = false; + this._currentTarget = null; + this._target = null; + this._eventPhase = Event.AT_TARGET; + this._timeStamp = new Date().getTime(); + this._preventDefault = false; + this._stopPropagation = false; +}; + /********************************************************************* This is our addEventListener function. It is bound to window, which is ok because window has such a function @@ -1136,6 +1154,7 @@ Third arg is not used cause I don't understand it. function addEventListener(ev, handler, notused) { +ev_before_changes = ev; ev = "on" + ev; var evarray = ev + "$$array"; // array of handlers var evorig = ev + "$$orig"; // original handler from html @@ -1149,7 +1168,7 @@ this[ev] = undefined; } this[evarray] = a; eval( -'this.' + ev + ' = function(){ var a = this.' + evarray + '; if(this.' + evorig + ') this.' + evorig + '(); for(var i = 0; i