diff --git a/CHANGELOG.md b/CHANGELOG.md index 82f3d744b..ce0c15e19 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -211,7 +211,7 @@ object is more consistent with `window.location`, accepted that interpretation. `Location.assign` did not load a page if the page was already loaded -in the browser. Changed it to load the page (add caching later on). +in the browser. Changed it to load the page (add caching later on). 196 Tests 2.6 sec to complete @@ -242,7 +242,7 @@ Added new page covering the browser API. ### Version 0.7.7 2010-12-28 -Fix JSDOM queue and with it issue #6. +Fix JSDOM queue and with it issue #6. 189 Tests 2.3 sec to complete @@ -254,9 +254,9 @@ HTML5 doesn't play nice with JSDOM, bringing back html-parser to handle innerHTML (full document parsing still handled by HTML5). Added documentation page for CSS selectors. - + Man pages now moved to section 7. - + Added zombie.version. 189 Tests diff --git a/README.md b/README.md index ea691f1f5..0823cfb86 100644 --- a/README.md +++ b/README.md @@ -221,7 +221,7 @@ figure out what it's doing. For example: browser.visit("http://thedead", function(err, browser, status) { if (err) throw(err.message); - ... + ... }); **Step 2:** Wait for it to finish processing, then dump the current diff --git a/spec/.scripts/jquery.js b/spec/.scripts/jquery.js index a4f114586..c53482c80 100644 --- a/spec/.scripts/jquery.js +++ b/spec/.scripts/jquery.js @@ -75,10 +75,10 @@ var jQuery = function( selector, context ) { // For matching the engine and version of the browser browserMatch, - + // Has the ready events already been bound? readyBound = false, - + // The functions to execute on DOM ready readyList = [], @@ -92,7 +92,7 @@ var jQuery = function( selector, context ) { slice = Array.prototype.slice, trim = String.prototype.trim, indexOf = Array.prototype.indexOf, - + // [[Class]] -> type pairs class2type = {}; @@ -111,7 +111,7 @@ jQuery.fn = jQuery.prototype = { this.length = 1; return this; } - + // The body element only exists once, optimize finding it if ( selector === "body" && !context && document.body ) { this.context = document; @@ -150,9 +150,9 @@ jQuery.fn = jQuery.prototype = { ret = jQuery.buildFragment( [ match[1] ], [ doc ] ); selector = (ret.cacheable ? ret.fragment.cloneNode(true) : ret.fragment).childNodes; } - + return jQuery.merge( this, selector ); - + // HANDLE: $("#id") } else { elem = document.getElementById( match[2] ); @@ -245,7 +245,7 @@ jQuery.fn = jQuery.prototype = { if ( jQuery.isArray( elems ) ) { push.apply( ret, elems ); - + } else { jQuery.merge( ret, elems ); } @@ -271,7 +271,7 @@ jQuery.fn = jQuery.prototype = { each: function( callback, args ) { return jQuery.each( this, callback, args ); }, - + ready: function( fn ) { // Attach the listeners jQuery.bindReady(); @@ -289,7 +289,7 @@ jQuery.fn = jQuery.prototype = { return this; }, - + eq: function( i ) { return i === -1 ? this.slice( i ) : @@ -314,7 +314,7 @@ jQuery.fn = jQuery.prototype = { return callback.call( elem, i, elem ); })); }, - + end: function() { return this.prevObject || jQuery(null); }, @@ -403,14 +403,14 @@ jQuery.extend({ return jQuery; }, - + // Is the DOM ready to be used? Set to true once it occurs. isReady: false, // A counter to track how many items to wait for before // the ready event fires. See #6781 readyWait: 1, - + // Handle when the DOM is ready ready: function( wait ) { // A third-party is pushing the ready event forwards @@ -454,7 +454,7 @@ jQuery.extend({ } } }, - + bindReady: function() { if ( readyBound ) { return; @@ -473,7 +473,7 @@ jQuery.extend({ if ( document.addEventListener ) { // Use the handy event callback document.addEventListener( "DOMContentLoaded", DOMContentLoaded, false ); - + // A fallback to window.onload, that will always work window.addEventListener( "load", jQuery.ready, false ); @@ -482,7 +482,7 @@ jQuery.extend({ // ensure firing before onload, // maybe late but safe also for iframes document.attachEvent("onreadystatechange", DOMContentLoaded); - + // A fallback to window.onload, that will always work window.attachEvent( "onload", jQuery.ready ); @@ -533,20 +533,20 @@ jQuery.extend({ if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) { return false; } - + // Not own constructor property must be Object if ( obj.constructor && !hasOwn.call(obj, "constructor") && !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) { return false; } - + // Own properties are enumerated firstly, so to speed up, // if last one is own, then all properties are own. - + var key; for ( key in obj ) {} - + return key === undefined || hasOwn.call( obj, key ); }, @@ -556,11 +556,11 @@ jQuery.extend({ } return true; }, - + error: function( msg ) { throw msg; }, - + parseJSON: function( data ) { if ( typeof data !== "string" || !data ) { return null; @@ -568,7 +568,7 @@ jQuery.extend({ // Make sure leading/trailing whitespace is removed (IE can't handle it) data = jQuery.trim( data ); - + // Make sure the incoming data is actual JSON // Logic borrowed from http://json.org/json2.js if ( rvalidchars.test(data.replace(rvalidescape, "@") @@ -710,7 +710,7 @@ jQuery.extend({ for ( var l = second.length; j < l; j++ ) { first[ i++ ] = second[ j ]; } - + } else { while ( second[j] !== undefined ) { first[ i++ ] = second[ j++ ]; @@ -790,7 +790,7 @@ jQuery.extend({ // The value/s can be optionally by executed if its a function access: function( elems, key, value, exec, fn, pass ) { var length = elems.length; - + // Setting many attributes if ( typeof key === "object" ) { for ( var k in key ) { @@ -798,19 +798,19 @@ jQuery.extend({ } return elems; } - + // Setting one attribute if ( value !== undefined ) { // Optionally, function values get executed if exec is true exec = !pass && exec && jQuery.isFunction(value); - + for ( var i = 0; i < length; i++ ) { fn( elems[i], key, exec ? value.call( elems[i], i, fn( elems[i], key ) ) : value, pass ); } - + return elems; } - + // Getting an attribute return length ? fn( elems[0], key ) : undefined; }, @@ -1115,7 +1115,7 @@ jQuery.extend({ // Please use with caution uuid: 0, - // Unique for each copy of jQuery on the page + // Unique for each copy of jQuery on the page expando: "jQuery" + jQuery.now(), // The following elements throw uncatchable exceptions if you @@ -1607,7 +1607,7 @@ jQuery.fn.extend({ var option = options[ i ]; // Don't return options that are disabled or in a disabled optgroup - if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && + if ( option.selected && (jQuery.support.optDisabled ? !option.disabled : option.getAttribute("disabled") === null) && (!option.parentNode.disabled || !jQuery.nodeName( option.parentNode, "optgroup" )) ) { // Get the specific value for the option @@ -1630,7 +1630,7 @@ jQuery.fn.extend({ if ( rradiocheck.test( elem.type ) && !jQuery.support.checkOn ) { return elem.getAttribute("value") === null ? "on" : elem.value; } - + // Everything else, we just grab the value return (elem.value || "").replace(rreturn, ""); @@ -1696,7 +1696,7 @@ jQuery.extend({ height: true, offset: true }, - + attr: function( elem, name, value, pass ) { // don't set attributes on text and comment nodes if ( !elem || elem.nodeType === 3 || elem.nodeType === 8 ) { @@ -1865,7 +1865,7 @@ jQuery.event = { var eventKey = elem.nodeType ? "events" : "__events__", events = elemData[ eventKey ], eventHandle = elemData.handle; - + if ( typeof events === "function" ) { // On plain objects events is a fn that holds the the data // which prevents this data from being JSON serialized @@ -1945,9 +1945,9 @@ jQuery.event = { } } } - - if ( special.add ) { - special.add.call( elem, handleObj ); + + if ( special.add ) { + special.add.call( elem, handleObj ); if ( !handleObj.handler.guid ) { handleObj.handler.guid = handler.guid; @@ -1986,7 +1986,7 @@ jQuery.event = { if ( !elemData || !events ) { return; } - + if ( typeof events === "function" ) { elemData = events; events = events.events; @@ -2024,7 +2024,7 @@ jQuery.event = { namespaces = type.split("."); type = namespaces.shift(); - namespace = new RegExp("(^|\\.)" + + namespace = new RegExp("(^|\\.)" + jQuery.map( namespaces.slice(0).sort(), fcleanup ).join("\\.(?:.*\\.)?") + "(\\.|$)"); } @@ -2186,7 +2186,7 @@ jQuery.event = { isClick = jQuery.nodeName( target, "a" ) && targetType === "click", special = jQuery.event.special[ targetType ] || {}; - if ( (!special._default || special._default.call( elem, event ) === false) && + if ( (!special._default || special._default.call( elem, event ) === false) && !isClick && !(target && target.nodeName && jQuery.noData[target.nodeName.toLowerCase()]) ) { try { @@ -2256,7 +2256,7 @@ jQuery.event = { event.handler = handleObj.handler; event.data = handleObj.data; event.handleObj = handleObj; - + var ret = handleObj.handler.apply( this, args ); if ( ret !== undefined ) { @@ -2355,7 +2355,7 @@ jQuery.event = { add: function( handleObj ) { jQuery.event.add( this, liveConvert( handleObj.origType, handleObj.selector ), - jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) ); + jQuery.extend({}, handleObj, {handler: liveHandler, guid: handleObj.handler.guid}) ); }, remove: function( handleObj ) { @@ -2385,7 +2385,7 @@ jQuery.removeEvent = document.removeEventListener ? if ( elem.removeEventListener ) { elem.removeEventListener( type, handle, false ); } - } : + } : function( elem, type, handle ) { if ( elem.detachEvent ) { elem.detachEvent( "on" + type, handle ); @@ -2432,7 +2432,7 @@ jQuery.Event.prototype = { if ( !e ) { return; } - + // if preventDefault exists run it on the original event if ( e.preventDefault ) { e.preventDefault(); @@ -2528,7 +2528,7 @@ if ( !jQuery.support.submitBubbles ) { return trigger( "submit", this, arguments ); } }); - + jQuery.event.add(this, "keypress.specialSubmit", function( e ) { var elem = e.target, type = elem.type; @@ -2590,7 +2590,7 @@ if ( !jQuery.support.changeBubbles ) { if ( e.type !== "focusout" || elem.type !== "radio" ) { jQuery.data( elem, "_change_data", val ); } - + if ( data === undefined || val === data ) { return; } @@ -2604,7 +2604,7 @@ if ( !jQuery.support.changeBubbles ) { jQuery.event.special.change = { filters: { - focusout: testChange, + focusout: testChange, beforedeactivate: testChange, @@ -2675,15 +2675,15 @@ if ( document.addEventListener ) { if ( focusCounts[fix]++ === 0 ) { document.addEventListener( orig, handler, true ); } - }, - teardown: function() { + }, + teardown: function() { if ( --focusCounts[fix] === 0 ) { document.removeEventListener( orig, handler, true ); } } }; - function handler( e ) { + function handler( e ) { e = jQuery.event.fix( e ); e.type = fix; return jQuery.event.trigger( e, null, e.target ); @@ -2700,7 +2700,7 @@ jQuery.each(["bind", "one"], function( i, name ) { } return this; } - + if ( jQuery.isFunction( data ) || data === false ) { fn = data; data = undefined; @@ -2740,20 +2740,20 @@ jQuery.fn.extend({ return this; }, - + delegate: function( selector, types, data, fn ) { return this.live( types, data, fn, selector ); }, - + undelegate: function( selector, types, fn ) { if ( arguments.length === 0 ) { return this.unbind( "live" ); - + } else { return this.die( types, null, fn, selector ); } }, - + trigger: function( type, data ) { return this.each(function() { jQuery.event.trigger( type, data, this ); @@ -2810,12 +2810,12 @@ jQuery.each(["live", "die"], function( i, name ) { var type, i = 0, match, namespaces, preType, selector = origSelector || this.selector, context = origSelector ? this : jQuery( this.context ); - + if ( typeof types === "object" && !types.preventDefault ) { for ( var key in types ) { context[ name ]( key, data, types[key], selector ); } - + return this; } @@ -2862,7 +2862,7 @@ jQuery.each(["live", "die"], function( i, name ) { context.unbind( "live." + liveConvert( type, selector ), fn ); } } - + return this; }; }); @@ -2881,7 +2881,7 @@ function liveHandler( event ) { if ( event.liveFired === this || !events || !events.live || event.button && event.type === "click" ) { return; } - + if ( event.namespace ) { namespace = new RegExp("(^|\\.)" + event.namespace.split(".").join("\\.(?:.*\\.)?") + "(\\.|$)"); } @@ -3029,7 +3029,7 @@ var Sizzle = function( selector, context, results, seed ) { if ( context.nodeType !== 1 && context.nodeType !== 9 ) { return []; } - + if ( !selector || typeof selector !== "string" ) { return results; } @@ -3039,7 +3039,7 @@ var Sizzle = function( selector, context, results, seed ) { contextXML = Sizzle.isXML( context ), parts = [], soFar = selector; - + // Reset the position of the chunker regexp (start from head) do { chunker.exec( "" ); @@ -3047,9 +3047,9 @@ var Sizzle = function( selector, context, results, seed ) { if ( m ) { soFar = m[3]; - + parts.push( m[1] ); - + if ( m[2] ) { extra = m[3]; break; @@ -3073,7 +3073,7 @@ var Sizzle = function( selector, context, results, seed ) { if ( Expr.relative[ selector ] ) { selector += parts.shift(); } - + set = posProcess( selector, set ); } } @@ -3202,7 +3202,7 @@ Sizzle.find = function( expr, context, isXML ) { for ( var i = 0, l = Expr.order.length; i < l; i++ ) { var match, type = Expr.order[i]; - + if ( (match = Expr.leftMatch[ type ].exec( expr )) ) { var left = match[1]; match.splice( 1, 1 ); @@ -3518,7 +3518,7 @@ var Expr = Sizzle.selectors = { ATTR: function( match, curLoop, inplace, result, not, isXML ) { var name = match[1].replace(/\\/g, ""); - + if ( !isXML && Expr.attrMap[name] ) { match[1] = Expr.attrMap[name]; } @@ -3549,7 +3549,7 @@ var Expr = Sizzle.selectors = { } else if ( Expr.match.POS.test( match[0] ) || Expr.match.CHILD.test( match[0] ) ) { return true; } - + return match; }, @@ -3559,7 +3559,7 @@ var Expr = Sizzle.selectors = { return match; } }, - + filters: { enabled: function( elem ) { return elem.disabled === false && elem.type !== "hidden"; @@ -3572,12 +3572,12 @@ var Expr = Sizzle.selectors = { checked: function( elem ) { return elem.checked === true; }, - + selected: function( elem ) { // Accessing this property makes selected-by-default // options in Safari work properly elem.parentNode.selectedIndex; - + return elem.selected === true; }, @@ -3703,21 +3703,21 @@ var Expr = Sizzle.selectors = { case "only": case "first": while ( (node = node.previousSibling) ) { - if ( node.nodeType === 1 ) { - return false; + if ( node.nodeType === 1 ) { + return false; } } - if ( type === "first" ) { - return true; + if ( type === "first" ) { + return true; } node = elem; case "last": while ( (node = node.nextSibling) ) { - if ( node.nodeType === 1 ) { - return false; + if ( node.nodeType === 1 ) { + return false; } } @@ -3730,22 +3730,22 @@ var Expr = Sizzle.selectors = { if ( first === 1 && last === 0 ) { return true; } - + var doneName = match[0], parent = elem.parentNode; - + if ( parent && (parent.sizcache !== doneName || !elem.nodeIndex) ) { var count = 0; - + for ( node = parent.firstChild; node; node = node.nextSibling ) { if ( node.nodeType === 1 ) { node.nodeIndex = ++count; } - } + } parent.sizcache = doneName; } - + var diff = elem.nodeIndex - last; if ( first === 0 ) { @@ -3764,7 +3764,7 @@ var Expr = Sizzle.selectors = { TAG: function( elem, match ) { return (match === "*" && elem.nodeType === 1) || elem.nodeName.toLowerCase() === match; }, - + CLASS: function( elem, match ) { return (" " + (elem.className || elem.getAttribute("class")) + " ") .indexOf( match ) > -1; @@ -3830,7 +3830,7 @@ var makeArray = function( array, results ) { results.push.apply( results, array ); return results; } - + return array; }; @@ -4077,7 +4077,7 @@ if ( document.querySelectorAll ) { if ( div.querySelectorAll && div.querySelectorAll(".TEST").length === 0 ) { return; } - + Sizzle = function( query, context, extra, seed ) { context = context || document; @@ -4115,7 +4115,7 @@ if ( document.querySelectorAll ) { } } } - + return oldSizzle(query, context, extra, seed); }; @@ -4137,7 +4137,7 @@ if ( document.querySelectorAll ) { // This should fail with an exception // Gecko does not error, returns false instead matches.call( document.documentElement, "[test!='']:sizzle" ); - + } catch( pseudoError ) { pseudoWorks = true; } @@ -4148,7 +4148,7 @@ if ( document.querySelectorAll ) { expr = expr.replace(/\=\s*([^'"\]]*)\s*\]/g, "='$1']"); if ( !Sizzle.isXML( node ) ) { - try { + try { if ( pseudoWorks || !Expr.match.PSEUDO.test( expr ) && !/!=/.test( expr ) ) { return matches.call( node, expr ); } @@ -4177,7 +4177,7 @@ if ( document.querySelectorAll ) { if ( div.getElementsByClassName("e").length === 1 ) { return; } - + Expr.order.splice(1, 0, "CLASS"); Expr.find.CLASS = function( match, context, isXML ) { if ( typeof context.getElementsByClassName !== "undefined" && !isXML ) { @@ -4228,7 +4228,7 @@ function dirCheck( dir, cur, doneName, checkSet, nodeCheck, isXML ) { if ( elem ) { var match = false; - + elem = elem[dir]; while ( elem ) { @@ -4281,7 +4281,7 @@ if ( document.documentElement.contains ) { Sizzle.isXML = function( elem ) { // documentElement is verified for cases where it doesn't yet exist - // (such as loading iframes in IE - #4833) + // (such as loading iframes in IE - #4833) var documentElement = (elem ? elem.ownerDocument || elem : 0).documentElement; return documentElement ? documentElement.nodeName !== "HTML" : false; @@ -4373,7 +4373,7 @@ jQuery.fn.extend({ filter: function( selector ) { return this.pushStack( winnow(this, selector, true), "filter", selector ); }, - + is: function( selector ) { return !!selector && jQuery.filter( selector, this ).length > 0; }, @@ -4391,7 +4391,7 @@ jQuery.fn.extend({ selector = selectors[i]; if ( !matches[selector] ) { - matches[selector] = jQuery.expr.match.POS.test( selector ) ? + matches[selector] = jQuery.expr.match.POS.test( selector ) ? jQuery( selector, context || this.context ) : selector; } @@ -4414,7 +4414,7 @@ jQuery.fn.extend({ return ret; } - var pos = POS.test( selectors ) ? + var pos = POS.test( selectors ) ? jQuery( selectors, context || this.context ) : null; for ( i = 0, l = this.length; i < l; i++ ) { @@ -4435,10 +4435,10 @@ jQuery.fn.extend({ } ret = ret.length > 1 ? jQuery.unique(ret) : ret; - + return this.pushStack( ret, "closest", selectors ); }, - + // Determine the position of an element within // the matched set of elements index: function( elem ) { @@ -4519,7 +4519,7 @@ jQuery.each({ }, function( name, fn ) { jQuery.fn[ name ] = function( until, selector ) { var ret = jQuery.map( this, fn, until ); - + if ( !runtil.test( name ) ) { selector = until; } @@ -4548,7 +4548,7 @@ jQuery.extend({ jQuery.find.matchesSelector(elems[0], expr) ? [ elems[0] ] : [] : jQuery.find.matches(expr, elems); }, - + dir: function( elem, dir, until ) { var matched = [], cur = elem[ dir ]; @@ -4770,7 +4770,7 @@ jQuery.fn.extend({ return set; } }, - + // keepData is for internal use only--do not document remove: function( selector, keepData ) { for ( var i = 0, elem; (elem = this[i]) != null; i++ ) { @@ -4785,7 +4785,7 @@ jQuery.fn.extend({ } } } - + return this; }, @@ -4801,7 +4801,7 @@ jQuery.fn.extend({ elem.removeChild( elem.firstChild ); } } - + return this; }, @@ -4952,9 +4952,9 @@ jQuery.fn.extend({ } else { results = jQuery.buildFragment( args, this, scripts ); } - + fragment = results.fragment; - + if ( fragment.childNodes.length === 1 ) { first = fragment = fragment.firstChild; } else { @@ -5062,18 +5062,18 @@ jQuery.each({ var ret = [], insert = jQuery( selector ), parent = this.length === 1 && this[0].parentNode; - + if ( parent && parent.nodeType === 11 && parent.childNodes.length === 1 && insert.length === 1 ) { insert[ original ]( this[0] ); return this; - + } else { for ( var i = 0, l = insert.length; i < l; i++ ) { var elems = (i > 0 ? this.clone(true) : this).get(); jQuery( insert[i] )[ original ]( elems ); ret = ret.concat( elems ); } - + return this.pushStack( ret, name, insert.selector ); } }; @@ -5161,7 +5161,7 @@ jQuery.extend({ for ( i = 0; ret[i]; i++ ) { if ( scripts && jQuery.nodeName( ret[i], "script" ) && (!ret[i].type || ret[i].type.toLowerCase() === "text/javascript") ) { scripts.push( ret[i].parentNode ? ret[i].parentNode.removeChild( ret[i] ) : ret[i] ); - + } else { if ( ret[i].nodeType === 1 ) { ret.splice.apply( ret, [i + 1, 0].concat(jQuery.makeArray(ret[i].getElementsByTagName("script"))) ); @@ -5173,22 +5173,22 @@ jQuery.extend({ return ret; }, - + cleanData: function( elems ) { var data, id, cache = jQuery.cache, special = jQuery.event.special, deleteExpando = jQuery.support.deleteExpando; - + for ( var i = 0, elem; (elem = elems[i]) != null; i++ ) { if ( elem.nodeName && jQuery.noData[elem.nodeName.toLowerCase()] ) { continue; } id = elem[ jQuery.expando ]; - + if ( id ) { data = cache[ id ]; - + if ( data && data.events ) { for ( var type in data.events ) { if ( special[ type ] ) { @@ -5199,14 +5199,14 @@ jQuery.extend({ } } } - + if ( deleteExpando ) { delete elem[ jQuery.expando ]; } else if ( elem.removeAttribute ) { elem.removeAttribute( jQuery.expando ); } - + delete cache[ id ]; } } @@ -5819,7 +5819,7 @@ jQuery.extend({ data = tmp; jQuery.handleSuccess( s, xhr, status, data ); jQuery.handleComplete( s, xhr, status, data ); - + if ( head ) { head.removeChild( script ); } @@ -6078,19 +6078,19 @@ jQuery.extend({ value = jQuery.isFunction(value) ? value() : value; s[ s.length ] = encodeURIComponent(key) + "=" + encodeURIComponent(value); }; - + // Set traditional to true for jQuery <= 1.3.2 behavior. if ( traditional === undefined ) { traditional = jQuery.ajaxSettings.traditional; } - + // If an array was passed in, assume that it is an array of form elements. if ( jQuery.isArray(a) || a.jquery ) { // Serialize the form elements jQuery.each( a, function() { add( this.name, this.value ); }); - + } else { // If traditional, encode the "old" way (the way 1.3.2 or older // did it), otherwise encode params recursively. @@ -6123,7 +6123,7 @@ function buildParams( prefix, obj, traditional, add ) { buildParams( prefix + "[" + ( typeof v === "object" || jQuery.isArray(v) ? i : "" ) + "]", v, traditional, add ); } }); - + } else if ( !traditional && obj != null && typeof obj === "object" ) { if ( jQuery.isEmptyObject( obj ) ) { add( prefix, "" ); @@ -6134,7 +6134,7 @@ function buildParams( prefix, obj, traditional, add ) { buildParams( prefix + "[" + k + "]", v, traditional, add ); }); } - + } else { // Serialize scalar item. add( prefix, obj ); @@ -6192,7 +6192,7 @@ jQuery.extend({ jQuery.event.trigger( "ajaxStop" ); } }, - + triggerGlobal: function( s, type, args ) { (s.context && s.context.url == null ? jQuery(s.context) : jQuery.event).trigger(type, args); }, @@ -6815,7 +6815,7 @@ if ( "getBoundingClientRect" in document.documentElement ) { jQuery.fn.offset = function( options ) { var elem = this[0], box; - if ( options ) { + if ( options ) { return this.each(function( i ) { jQuery.offset.setOffset( this, options, i ); }); @@ -6857,7 +6857,7 @@ if ( "getBoundingClientRect" in document.documentElement ) { jQuery.fn.offset = function( options ) { var elem = this[0]; - if ( options ) { + if ( options ) { return this.each(function( i ) { jQuery.offset.setOffset( this, options, i ); }); @@ -6976,7 +6976,7 @@ jQuery.offset = { return { top: top, left: left }; }, - + setOffset: function( elem, options, i ) { var position = jQuery.css( elem, "position" ); @@ -7010,7 +7010,7 @@ jQuery.offset = { if (options.left != null) { props.left = (options.left - curOffset.left) + curLeft; } - + if ( "using" in options ) { options.using.call( elem, props ); } else { @@ -7070,7 +7070,7 @@ jQuery.each( ["Left", "Top"], function( i, name ) { jQuery.fn[ method ] = function(val) { var elem = this[0], win; - + if ( !elem ) { return null; } @@ -7138,7 +7138,7 @@ jQuery.each([ "Height", "Width" ], function( i, name ) { if ( !elem ) { return size == null ? null : this; } - + if ( jQuery.isFunction( size ) ) { return this.each(function( i ) { var self = jQuery( this ); diff --git a/spec/browser-spec.coffee b/spec/browser-spec.coffee index e2553939b..42ffc6439 100644 --- a/spec/browser-spec.coffee +++ b/spec/browser-spec.coffee @@ -180,7 +180,7 @@ vows.describe("Browser").addBatch( browser.window.location = "http://localhost:3003/" browser.wait() "should fire done event": (browser)-> assert.ok browser.visit - + "content selection": zombie.wants "http://localhost:3003/living" "query text": diff --git a/spec/cookie-spec.coffee b/spec/cookie-spec.coffee index 3a4985a65..b6f9e966a 100644 --- a/spec/cookie-spec.coffee +++ b/spec/cookie-spec.coffee @@ -105,8 +105,8 @@ vows.describe("Cookies").addBatch( "should pass path cookies to server": (cookies)-> assert.equal cookies._path1, "here" assert.equal cookies._path2, "here" - "should pass cookies that specified a different path when they were assigned": (cookies)-> assert.equal cookies._path5, "here" - "should pass cookies that didn't specify a path when they were assigned": (cookies)-> assert.equal cookies._path6, "here" + "should pass cookies that specified a different path when they were assigned": (cookies)-> assert.equal cookies._path5, "here" + "should pass cookies that didn't specify a path when they were assigned": (cookies)-> assert.equal cookies._path6, "here" "should not pass unrelated path cookies to server": (cookies)-> assert.isUndefined cookies._path3 assert.isUndefined cookies._path4 diff --git a/spec/forms-spec.coffee b/spec/forms-spec.coffee index 86a6df4fb..d268de0a7 100644 --- a/spec/forms-spec.coffee +++ b/spec/forms-spec.coffee @@ -43,14 +43,14 @@ brains.get "/forms/form", (req, res)-> res.send """ - + Second address - + - +
diff --git a/src/zombie/browser.coffee b/src/zombie/browser.coffee index 00d1c98f5..ee6327a44 100644 --- a/src/zombie/browser.coffee +++ b/src/zombie/browser.coffee @@ -39,7 +39,7 @@ class Browser extends require("events").EventEmitter # # User agent string sent to server. @userAgent = "Mozilla/5.0 Chrome/10.0.613.0 Safari/534.15 Zombie.js/#{exports.version}" - + # ### withOptions(options, fn) # @@ -66,7 +66,7 @@ class Browser extends require("events").EventEmitter # Windows # ------- - + window = null # ### browser.open() => Window # @@ -148,24 +148,24 @@ class Browser extends require("events").EventEmitter this.fire = (name, target, options, callback)-> [callback, options] = [options, null] if typeof(options) == 'function' options ?= {} - + klass = options.klass || if (name in mouseEventNames) then "MouseEvents" else "HTMLEvents" bubbles = options.bubbles ? true cancelable = options.cancelable ? true - + event = window.document.createEvent(klass) event.initEvent(name, bubbles, cancelable) - + if options.attributes? for key, value of options.attributes event[key] = value - + target.dispatchEvent event - + @wait callback if callback - + mouseEventNames = ['mousedown', 'mousemove', 'mouseup'] - + # ### browser.clock => Number # # The current system time according to the browser (see also @@ -509,7 +509,7 @@ class Browser extends require("events").EventEmitter option = findOption(selector, value) @unselectOption(option) return this - + # ### browser.unselectOption(option) => this # # Unselects an option. diff --git a/src/zombie/cookies.coffee b/src/zombie/cookies.coffee index def8c0fa6..0abe7a3f6 100644 --- a/src/zombie/cookies.coffee +++ b/src/zombie/cookies.coffee @@ -65,7 +65,7 @@ class Cookies # * options -- Options max-age, expires, secure, domain, path this.set = (name, value, options = {})-> return if options.domain && !domainMatch(options.domain, hostname) - + name = name.toLowerCase() state = { value: value.toString() } if options.expires @@ -74,13 +74,13 @@ class Cookies maxage = options["max-age"] state.expires = browser.clock + maxage if typeof maxage is "number" state.secure = true if options.secure - + if typeof state.expires is "number" && state.expires <= browser.clock @remove(name, options) else path_without_resource = pathname.match(/.*\//) # everything but what trails the last / in_domain = cookies[options.domain || hostname] ||= {} - in_path = in_domain[options.path || path_without_resource] ||= {} + in_path = in_domain[options.path || path_without_resource] ||= {} in_path[name] = state #### cookies(host, path).remove(name, options?) @@ -115,7 +115,7 @@ class Cookies fields = cookie.split(/;+/) first = fields[0].trim() [name, value] = first.split(/\=/, 2) - + options = { value: value } for field in fields [key, val] = field.trim().split(/\=/, 2) @@ -125,7 +125,7 @@ class Cookies when "expires" then options.expires = new Date(dequote(val)) when "max-age" then options['max-age'] = parseInt(dequote(val), 10) when "secure" then options.secure = true - + @set(name, value, options) #### cookies(host, path).addHeader(headers) diff --git a/src/zombie/eventloop.coffee b/src/zombie/eventloop.coffee index 735bca164..b99cbcc14 100644 --- a/src/zombie/eventloop.coffee +++ b/src/zombie/eventloop.coffee @@ -11,7 +11,7 @@ class EventLoop # # Implements window.setTimeout using event queue this.setTimeout = (fn, delay)-> - timer = + timer = when: browser.clock + delay timeout: true fire: => @@ -27,7 +27,7 @@ class EventLoop # # Implements window.setInterval using event queue this.setInterval = (fn, delay)-> - timer = + timer = when: browser.clock + delay interval: true fire: => @@ -91,7 +91,7 @@ class EventLoop browser.clock = earliest.when if browser.clock < earliest.when earliest.fire() if event - try + try event() done = false if typeof terminate is "number" @@ -119,7 +119,7 @@ class EventLoop window[fn] = this[fn] window.perform = this.perform window.wait = (terminate, callback)=> this.wait(window, terminate, callback) - window.request = this.request + window.request = this.request this.dump = ()-> [ "The time: #{browser.clock}", diff --git a/src/zombie/history.coffee b/src/zombie/history.coffee index 4403fcf75..21ede42da 100644 --- a/src/zombie/history.coffee +++ b/src/zombie/history.coffee @@ -48,7 +48,7 @@ class History else # Load new page for now (but later on use caching). resource url - + # Make a request to external resource. We use this to fetch pages and # submit forms, see _loadPage and _submit. resource = (url, method, data, headers)=> diff --git a/src/zombie/protocol.coffee b/src/zombie/protocol.coffee index dc53d82a9..74ed17969 100644 --- a/src/zombie/protocol.coffee +++ b/src/zombie/protocol.coffee @@ -95,7 +95,7 @@ class Context last = command command.invoke() - # Send a response of the specified type. + # Send a response of the specified type. respond = (stream, type, value)-> switch type when ERROR then stream.write "-#{value.message}\r\n" diff --git a/src/zombie/resources.coffee b/src/zombie/resources.coffee index 2164d779d..24d56aa07 100644 --- a/src/zombie/resources.coffee +++ b/src/zombie/resources.coffee @@ -121,7 +121,7 @@ class Resources extends Array # # The callback is called with error and response (see `HTTPResponse`). this.request = (method, url, data, headers, callback)-> - window.perform (done)-> + window.perform (done)-> makeRequest method, url, data, headers, null, (error, response)-> done() callback error, response @@ -214,7 +214,7 @@ class Resources extends Array url.port ||= if secure then 443 else 80 client = HTTP.createClient(url.port, url.hostname, secure) request = client.request(method, "#{url.pathname}#{url.search || ""}", headers) - + # First request has not resource, so create it and add to # Resources. After redirect, we have a resource we're using. unless resource @@ -233,7 +233,7 @@ class Resources extends Array # Turn body from string into a String, so we can add property getters. resource.response = new HTTPResponse(url, response.statusCode, response.headers, body) - + error = null switch response.statusCode when 200, 201, 202, 204 diff --git a/src/zombie/storage.coffee b/src/zombie/storage.coffee index 945996e53..a68355c16 100644 --- a/src/zombie/storage.coffee +++ b/src/zombie/storage.coffee @@ -52,7 +52,7 @@ class StorageArea this.__defineGetter__ "pairs", -> [k,v] for k,v of items this.toString = -> ("#{k} = #{v}" for k,v of items).join("\n") - + # Implementation of the Storage interface, used by local and session storage. class Storage diff --git a/src/zombie/xhr.coffee b/src/zombie/xhr.coffee index 2cb2caebe..131d3b597 100644 --- a/src/zombie/xhr.coffee +++ b/src/zombie/xhr.coffee @@ -48,7 +48,7 @@ XMLHttpRequest = (window)-> @abort = -> aborted = true reset() - + headers = {} @setRequestHeader = (header, value)-> headers[header.toString().toLowerCase()] = value.toString() # Allow calling send method. @@ -59,7 +59,7 @@ XMLHttpRequest = (window)-> @_error = new core.DOMException(core.ABORT_ERR, "Request aborted") stateChanged 4 reset() - + # Make the actual request: called again when dealing with a redirect. window.resources.request method, url, data, headers, (error, response)=> if error