X-Git-Url: http://git.asbjorn.biz/?a=blobdiff_plain;f=build%2Fruntest%2Fenv.js;h=7a1352af1429aee65d84ef7b4a86a69aaa138e2f;hb=b83a6b7a323d63280fe325b06e1c38d26b5031a9;hp=30cd8f1b447f41612b235d56c7c64f212ceb10eb;hpb=e155a6ae51fad3649e77ebc6f784e4fc6b957ad1;p=jquery.git diff --git a/build/runtest/env.js b/build/runtest/env.js index 30cd8f1..7a1352a 100644 --- a/build/runtest/env.js +++ b/build/runtest/env.js @@ -106,7 +106,7 @@ var window = this; return makeNode( this._dom.getDocumentElement() ); }, get ownerDocument(){ - return this; + return null; }, addEventListener: function(){}, removeEventListener: function(){}, @@ -203,6 +203,17 @@ var window = this; window.DOMElement = function(elem){ this._dom = elem; + this.style = {}; + + // Load CSS info + var styles = (new String(this.getAttribute("style") || "")) + .split(/\s*;\s*/); + + for ( var i = 0; i < styles.length; i++ ) { + var style = styles[i].split(/\s*:\s*/); + if ( style.length == 2 ) + this.style[ style[0] ] = style[1]; + } }; DOMElement.prototype = extend( new DOMNode(), { @@ -281,13 +292,43 @@ var window = this; offsetHeight: 0, offsetWidth: 0, - get disabled() { return !!this.getAttribute("disabled"); }, + get disabled() { + var val = this.getAttribute("disabled"); + return val != "false" && !!val; + }, set disabled(val) { return this.setAttribute("disabled",val); }, - get checked() { return !!this.getAttribute("checked"); }, + get checked() { + var val = this.getAttribute("checked"); + return val != "false" && !!val; + }, set checked(val) { return this.setAttribute("checked",val); }, - get selected() { return !!this.getAttribute("selected"); }, + get selected() { + if ( !this._selectDone ) { + this._selectDone = true; + + if ( this.nodeName == "OPTION" && !this.parentNode.getAttribute("multiple") ) { + var opt = this.parentNode.getElementsByTagName("option"); + + if ( this == opt[0] ) { + var select = true; + + for ( var i = 1; i < opt.length; i++ ) + if ( opt[i].selected ) { + select = false; + break; + } + + if ( select ) + this.selected = true; + } + } + } + + var val = this.getAttribute("selected"); + return val != "false" && !!val; + }, set selected(val) { return this.setAttribute("selected",val); }, get className() { return this.getAttribute("class") || ""; }, @@ -343,7 +384,9 @@ var window = this; submit: function(){}, focus: function(){}, blur: function(){}, - elements: [] + get elements(){ + return this.getElementsByTagName("*"); + } }); // Helper method for extending one object with another