Commit de9bed31 authored by Chad Killingsworth's avatar Chad Killingsworth Committed by Dave Methvin

Make unit tests friendly to Closure Compiler. Closes gh-845.

    Conflicts:
    	test/unit/effects.js
    	test/unit/offset.js
parent 3dc77c4b
......@@ -9,7 +9,8 @@
"trailing": true,
"undef": true,
"smarttabs": true,
"maxerr": 100
"maxerr": 100,
"sub": true
},
"globals": {
"define": true,
......
This diff is collapsed.
......@@ -23,18 +23,18 @@ test("jQuery.propFix integrity test", function() {
// overwrites don't occur
// This is simply for better code coverage and future proofing.
var props = {
tabindex: "tabIndex",
readonly: "readOnly",
"tabindex": "tabIndex",
"readonly": "readOnly",
"for": "htmlFor",
"class": "className",
maxlength: "maxLength",
cellspacing: "cellSpacing",
cellpadding: "cellPadding",
rowspan: "rowSpan",
colspan: "colSpan",
usemap: "useMap",
frameborder: "frameBorder",
contenteditable: "contentEditable"
"maxlength": "maxLength",
"cellspacing": "cellSpacing",
"cellpadding": "cellPadding",
"rowspan": "rowSpan",
"colspan": "colSpan",
"usemap": "useMap",
"frameborder": "frameBorder",
"contenteditable": "contentEditable"
};
if ( !jQuery.support.enctype ) {
......@@ -155,14 +155,14 @@ test("attr(String, Function)", function() {
test("attr(Hash)", function() {
expect(3);
var pass = true;
jQuery("div").attr({foo: "baz", zoo: "ping"}).each(function(){
jQuery("div").attr({"foo": "baz", "zoo": "ping"}).each(function(){
if ( this.getAttribute("foo") != "baz" && this.getAttribute("zoo") != "ping" ) {
pass = false;
}
});
ok( pass, "Set Multiple Attributes" );
equal( jQuery("#text1").attr({value: function() { return this.id; }})[0].value, "text1", "Set attribute to computed value #1" );
equal( jQuery("#text1").attr({title: function(i) { return i; }}).attr("title"), "0", "Set attribute to computed value #2");
equal( jQuery("#text1").attr({"value": function() { return this["id"]; }})[0].value, "text1", "Set attribute to computed value #1" );
equal( jQuery("#text1").attr({"title": function(i) { return i; }}).attr("title"), "0", "Set attribute to computed value #2");
});
test("attr(String, Object)", function() {
......@@ -288,11 +288,11 @@ test("attr(String, Object)", function() {
var table = jQuery("#table").append("<tr><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr><tr><td>cell</td><td>cell</td></tr>"),
td = table.find("td:first");
td.attr("rowspan", "2");
equal( td[0].rowSpan, 2, "Check rowspan is correctly set" );
equal( td[0]["rowSpan"], 2, "Check rowspan is correctly set" );
td.attr("colspan", "2");
equal( td[0].colSpan, 2, "Check colspan is correctly set" );
equal( td[0]["colSpan"], 2, "Check colspan is correctly set" );
table.attr("cellspacing", "2");
equal( table[0].cellSpacing, "2", "Check cellspacing is correctly set" );
equal( table[0]["cellSpacing"], "2", "Check cellspacing is correctly set" );
equal( jQuery("#area1").attr("value"), "foobar", "Value attribute retrieves the property for backwards compatibility." );
......@@ -381,26 +381,26 @@ test("attr(jquery_method)", function(){
if ( jQuery.fn.width ) {
expected += 2;
attrObj.width = 10;
attrObj["width"] = 10;
}
if ( jQuery.fn.offset ) {
expected += 2;
attrObj.offset = { top: 1, left: 0 };
attrObj["offset"] = { "top": 1, "left": 0 };
}
if ( jQuery.css ) {
expected += 3;
attrObj.css = { paddingLeft: 1, paddingRight: 1 };
attrObj["css"] = { "paddingLeft": 1, "paddingRight": 1 };
}
expect( expected );
// one at a time
$elem.attr( { html: "foo" }, true );
$elem.attr( { "html": "foo" }, true );
equal( elem.innerHTML, "foo", "attr(html)" );
$elem.attr( { text: "bar" }, true );
$elem.attr( { "text": "bar" }, true );
equal( elem.innerHTML, "bar", "attr(text)" );
// Multiple attributes
......@@ -409,7 +409,7 @@ test("attr(jquery_method)", function(){
if ( jQuery.fn.width ) {
equal( elem.style.width, "10px", "attr({width:})" );
$elem.attr( { height: 10 }, true );
$elem.attr( { "height": 10 }, true );
equal( elem.style.height, "10px", "attr(height)" );
}
......@@ -424,7 +424,7 @@ test("attr(jquery_method)", function(){
equal( elem.style.paddingLeft, "1px", "attr({css:})" );
equal( elem.style.paddingRight, "1px", "attr({css:})" );
$elem.attr( { css: { color: "red" } }, true );
$elem.attr( { "css": { "color": "red" } }, true );
ok( /^(#ff0000|red)$/i.test( elem.style.color ), "attr(css)" );
}
});
......@@ -579,9 +579,9 @@ test("prop(String, Object)", function() {
$body = jQuery( body );
ok( $body.prop("nextSibling") === null, "Make sure a null expando returns null" );
body.foo = "bar";
body["foo"] = "bar";
equal( $body.prop("foo"), "bar", "Make sure the expando is preferred over the dom attribute" );
body.foo = undefined;
body["foo"] = undefined;
ok( $body.prop("foo") === undefined, "Make sure the expando is preferred over the dom attribute, even if undefined" );
var select = document.createElement("select"), optgroup = document.createElement("optgroup"), option = document.createElement("option");
......@@ -673,17 +673,17 @@ test("removeProp(String)", function() {
textNode = document.createTextNode("some text"),
obj = {};
strictEqual( jQuery( "#firstp" ).prop( "nonexisting", "foo" ).removeProp( "nonexisting" )[0].nonexisting, undefined, "removeprop works correctly on DOM element nodes" );
strictEqual( jQuery( "#firstp" ).prop( "nonexisting", "foo" ).removeProp( "nonexisting" )[0]["nonexisting"], undefined, "removeprop works correctly on DOM element nodes" );
jQuery.each( [document, obj], function( i, ele ) {
var $ele = jQuery( ele );
$ele.prop( "nonexisting", "foo" ).removeProp( "nonexisting" );
strictEqual( ele.nonexisting, undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." );
strictEqual( ele["nonexisting"], undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." );
});
jQuery.each( [commentNode, textNode, attributeNode], function( i, ele ) {
var $ele = jQuery( ele );
$ele.prop( "nonexisting", "foo" ).removeProp( "nonexisting" );
strictEqual( ele.nonexisting, undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." );
strictEqual( ele["nonexisting"], undefined, "removeProp works correctly on non DOM element nodes (bug #7500)." );
});
});
......@@ -898,7 +898,7 @@ test("val(select) after form.reset() (Bug #2551)", function() {
jQuery("#kkk").val( "gf" );
document.kk.reset();
document["kk"].reset();
equal( jQuery("#kkk")[0].value, "cf", "Check value of select after form reset." );
equal( jQuery("#kkk").val(), "cf", "Check value of select after form reset." );
......
......@@ -209,14 +209,14 @@ test( "jQuery.Callbacks( options ) - options are copied", function() {
expect( 1 );
var options = {
unique: true
"unique": true
},
cb = jQuery.Callbacks( options ),
count = 0,
fn = function() {
ok( !( count++ ), "called once" );
};
options.unique = false;
options["unique"] = false;
cb.add( fn, fn );
cb.fire();
});
......
This diff is collapsed.
......@@ -10,11 +10,11 @@ test("css(String|Hash)", function() {
ok( jQuery("#nothiddendiv").is(":visible"), "Modifying CSS display: Assert element is visible" );
jQuery("#nothiddendiv").css({ display: "none" });
ok( !jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is hidden" );
var $child = jQuery("#nothiddendivchild").css({ width: "20%", height: "20%" });
var $child = jQuery("#nothiddendivchild").css({ "width": "20%", "height": "20%" });
notEqual( $child.css("width"), "20px", "Retrieving a width percentage on the child of a hidden div returns percentage" );
notEqual( $child.css("height"), "20px", "Retrieving a height percentage on the child of a hidden div returns percentage" );
jQuery("#nothiddendiv").css({display: "block"});
jQuery("#nothiddendiv").css({"display": "block"});
ok( jQuery("#nothiddendiv").is(":visible"), "Modified CSS display: Assert element is visible");
ok( jQuery(window).is(":visible"), "Calling is(':visible') on window does not throw an error in IE.");
ok( jQuery(document).is(":visible"), "Calling is(':visible') on document does not throw an error in IE.");
......@@ -26,7 +26,7 @@ test("css(String|Hash)", function() {
equal( div.css("width"), "0px", "Width on disconnected node." );
equal( div.css("height"), "0px", "Height on disconnected node." );
div.css({ width: 4, height: 4 });
div.css({ "width": 4, "height": 4 });
equal( div.css("width"), "4px", "Width on disconnected node." );
equal( div.css("height"), "4px", "Height on disconnected node." );
......@@ -40,10 +40,10 @@ test("css(String|Hash)", function() {
div2.remove();
// handle negative numbers by setting to zero #11604
jQuery("#nothiddendiv").css( {width: 1, height: 1} );
jQuery("#nothiddendiv").css( {"width": 1, "height": 1} );
var width = parseFloat(jQuery("#nothiddendiv").css("width")), height = parseFloat(jQuery("#nothiddendiv").css("height"));
jQuery("#nothiddendiv").css({ overflow:"hidden", width: -1, height: -1 });
jQuery("#nothiddendiv").css({ "overflow":"hidden", "width": -1, "height": -1 });
equal( parseFloat(jQuery("#nothiddendiv").css("width")), 0, "Test negative width set to 0");
equal( parseFloat(jQuery("#nothiddendiv").css("height")), 0, "Test negative height set to 0");
......@@ -54,17 +54,17 @@ test("css(String|Hash)", function() {
jQuery("#floatTest").css({"font-size": "30px"});
equal( jQuery("#floatTest").css("font-size"), "30px", "Modified CSS font-size: Assert font-size is 30px");
jQuery.each("0,0.25,0.5,0.75,1".split(","), function(i, n) {
jQuery("#foo").css({opacity: n});
jQuery("#foo").css({"opacity": n});
equal( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a String" );
jQuery("#foo").css({opacity: parseFloat(n)});
jQuery("#foo").css({"opacity": parseFloat(n)});
equal( jQuery("#foo").css("opacity"), parseFloat(n), "Assert opacity is " + parseFloat(n) + " as a Number" );
});
jQuery("#foo").css({opacity: ""});
jQuery("#foo").css({"opacity": ""});
equal( jQuery("#foo").css("opacity"), "1", "Assert opacity is 1 when set to an empty String" );
equal( jQuery("#empty").css("opacity"), "0", "Assert opacity is accessible via filter property set in stylesheet in IE" );
jQuery("#empty").css({ opacity: "1" });
jQuery("#empty").css({ "opacity": "1" });
equal( jQuery("#empty").css("opacity"), "1", "Assert opacity is taken from style attribute when set vs stylesheet in IE with filters" );
jQuery.support.opacity ?
ok(true, "Requires the same number of tests"):
......@@ -121,7 +121,7 @@ test("css() explicit and relative values", function() {
expect(29);
var $elem = jQuery("#nothiddendiv");
$elem.css({ width: 1, height: 1, paddingLeft: "1px", opacity: 1 });
$elem.css({ "width": 1, "height": 1, "paddingLeft": "1px", "opacity": 1 });
equal( $elem.css("width"), "1px", "Initial css set or width/height works (hash)" );
equal( $elem.css("paddingLeft"), "1px", "Initial css set of paddingLeft works (hash)" );
equal( $elem.css("opacity"), "1", "Initial css set of opacity works (hash)" );
......@@ -129,13 +129,13 @@ test("css() explicit and relative values", function() {
$elem.css({ width: "+=9" });
equal( $elem.css("width"), "10px", "'+=9' on width (hash)" );
$elem.css({ width: "-=9" });
$elem.css({ "width": "-=9" });
equal( $elem.css("width"), "1px", "'-=9' on width (hash)" );
$elem.css({ width: "+=9px" });
$elem.css({ "width": "+=9px" });
equal( $elem.css("width"), "10px", "'+=9px' on width (hash)" );
$elem.css({ width: "-=9px" });
$elem.css({ "width": "-=9px" });
equal( $elem.css("width"), "1px", "'-=9px' on width (hash)" );
$elem.css( "width", "+=9" );
......@@ -156,16 +156,16 @@ test("css() explicit and relative values", function() {
$elem.css( "width", "+=-9px" );
equal( $elem.css("width"), "1px", "'+=-9px' on width (params)" );
$elem.css({ paddingLeft: "+=4" });
$elem.css({ "paddingLeft": "+=4" });
equal( $elem.css("paddingLeft"), "5px", "'+=4' on paddingLeft (hash)" );
$elem.css({ paddingLeft: "-=4" });
$elem.css({ "paddingLeft": "-=4" });
equal( $elem.css("paddingLeft"), "1px", "'-=4' on paddingLeft (hash)" );
$elem.css({ paddingLeft: "+=4px" });
$elem.css({ "paddingLeft": "+=4px" });
equal( $elem.css("paddingLeft"), "5px", "'+=4px' on paddingLeft (hash)" );
$elem.css({ paddingLeft: "-=4px" });
$elem.css({ "paddingLeft": "-=4px" });
equal( $elem.css("paddingLeft"), "1px", "'-=4px' on paddingLeft (hash)" );
$elem.css({ "padding-left": "+=4" });
......@@ -192,10 +192,10 @@ test("css() explicit and relative values", function() {
$elem.css( "padding-left", "-=4px" );
equal( $elem.css("paddingLeft"), "1px", "'-=4px' on padding-left (params)" );
$elem.css({ opacity: "-=0.5" });
$elem.css({ "opacity": "-=0.5" });
equal( $elem.css("opacity"), "0.5", "'-=0.5' on opacity (hash)" );
$elem.css({ opacity: "+=0.5" });
$elem.css({ "opacity": "+=0.5" });
equal( $elem.css("opacity"), "1", "'+=0.5' on opacity (hash)" );
$elem.css( "opacity", "-=0.5" );
......@@ -365,7 +365,7 @@ test("css(Object) where values are Functions", function() {
var index = 0;
jQuery("#cssFunctionTest div").css({fontSize: function() {
jQuery("#cssFunctionTest div").css({"fontSize": function() {
var size = sizes[index];
index++;
return size;
......@@ -395,7 +395,7 @@ test("css(Object) where values are Functions with incoming values", function() {
var index = 0;
jQuery("#cssFunctionTest div").css({fontSize: function() {
jQuery("#cssFunctionTest div").css({"fontSize": function() {
var size = sizes[index];
index++;
return size;
......@@ -486,7 +486,7 @@ test("show(); hide()", function() {
test("show() resolves correct default display #8099", function() {
expect(7);
var tt8099 = jQuery("<tt/>").appendTo("body"),
dfn8099 = jQuery("<dfn/>", { html: "foo"}).appendTo("body");
dfn8099 = jQuery("<dfn/>", { "html": "foo"}).appendTo("body");
equal( tt8099.css("display"), "none", "default display override for all tt" );
equal( tt8099.show().css("display"), "inline", "Correctly resolves display:inline" );
......@@ -621,7 +621,7 @@ test("internal ref to elem.runtimeStyle (bug #7608)", function () {
var result = true;
try {
jQuery("#foo").css( { width: "0%" } ).css("width");
jQuery("#foo").css( { "width": "0%" } ).css("width");
} catch (e) {
result = false;
}
......@@ -634,8 +634,8 @@ test("marginRight computed style (bug #3333)", function() {
var $div = jQuery("#foo");
$div.css({
width: "1px",
marginRight: 0
"width": "1px",
"marginRight": 0
});
equal($div.css("marginRight"), "0px", "marginRight correctly calculated with a width and display block");
......@@ -643,9 +643,9 @@ test("marginRight computed style (bug #3333)", function() {
test("jQuery.cssProps behavior, (bug #8402)", function() {
var div = jQuery( "<div>" ).appendTo(document.body).css({
position: "absolute",
top: 0,
left: 10
"position": "absolute",
"top": 0,
"left": 10
});
jQuery.cssProps.top = "left";
equal( div.css("top"), "10px", "the fixed property is used when accessing the computed style");
......@@ -662,16 +662,16 @@ test("widows & orphans #8936", function () {
if ( "widows" in $p[0].style ) {
expect(4);
$p.css({
widows: 0,
orphans: 0
"widows": 0,
"orphans": 0
});
equal( $p.css("widows") || jQuery.style( $p[0], "widows" ), 0, "widows correctly start with value 0");
equal( $p.css("orphans") || jQuery.style( $p[0], "orphans" ), 0, "orphans correctly start with value 0");
$p.css({
widows: 3,
orphans: 3
"widows": 3,
"orphans": 3
});
equal( $p.css("widows") || jQuery.style( $p[0], "widows" ), 3, "widows correctly set to 3");
......
......@@ -3,7 +3,7 @@ module("data", { teardown: moduleTeardown });
test("expando", function(){
expect(1);
equal("expando" in jQuery, true, "jQuery is exposing the expando");
equal(jQuery.expando !== undefined, true, "jQuery is exposing the expando");
});
function dataTests (elem) {
......@@ -29,14 +29,14 @@ function dataTests (elem) {
strictEqual( jQuery.hasData(elem), false, "jQuery.hasData agrees no data exists even when an empty data obj exists" );
dataObj.foo = "bar";
dataObj["foo"] = "bar";
equal( jQuery.data(elem, "foo"), "bar", "Data is readable by jQuery.data when set directly on a returned data object" );
strictEqual( jQuery.hasData(elem), true, "jQuery.hasData agrees data exists when data exists" );
jQuery.data(elem, "foo", "baz");
equal( jQuery.data(elem, "foo"), "baz", "Data can be changed by jQuery.data" );
equal( dataObj.foo, "baz", "Changes made through jQuery.data propagate to referenced data object" );
equal( dataObj["foo"], "baz", "Changes made through jQuery.data propagate to referenced data object" );
jQuery.data(elem, "foo", undefined);
equal( jQuery.data(elem, "foo"), "baz", "Data is not unset by passing undefined to jQuery.data" );
......@@ -197,7 +197,7 @@ test(".data()", function() {
dataObj = jQuery.extend(true, {}, jQuery(obj).data());
deepEqual( dataObj, { foo: "baz" }, "Retrieve data object from a wrapped JS object (#7524)" );
deepEqual( dataObj, { "foo": "baz" }, "Retrieve data object from a wrapped JS object (#7524)" );
});
test(".data(String) and .data(String, Object)", function() {
......@@ -428,8 +428,8 @@ test(".data(Object)", function() {
jqobj = jQuery(obj);
jqobj.data("test", "unset");
jqobj.data({ "test": "in", "test2": "in2" });
equal( jQuery.data(obj).test, "in", "Verify setting an object on an object extends the data object" );
equal( obj.test2, undefined, "Verify setting an object on an object does not extend the object" );
equal( jQuery.data(obj)["test"], "in", "Verify setting an object on an object extends the data object" );
equal( obj["test2"], undefined, "Verify setting an object on an object does not extend the object" );
// manually clean up detached elements
div.remove();
......@@ -463,7 +463,7 @@ test("jQuery.removeData", function() {
jQuery.data(div, {
"test3 test4": "testing",
test3: "testing"
"test3": "testing"
});
jQuery.removeData( div, "test3 test4" );
ok( !jQuery.data(div, "test3 test4"), "Multiple delete with spaces deleted key with exact name" );
......@@ -505,7 +505,7 @@ if (window.JSON && window.JSON.stringify) {
test("JSON serialization (#8108)", function () {
expect(1);
var obj = { foo: "bar" };
var obj = { "foo": "bar" };
jQuery.data(obj, "hidden", true);
equal( JSON.stringify(obj), "{\"foo\":\"bar\"}", "Expando is hidden from JSON.stringify" );
......@@ -518,12 +518,12 @@ test("jQuery.data should follow html5 specification regarding camel casing", fun
var div = jQuery("<div id='myObject' data-w-t-f='ftw' data-big-a-little-a='bouncing-b' data-foo='a' data-foo-bar='b' data-foo-bar-baz='c'></div>")
.prependTo("body");
equal( div.data().wTF, "ftw", "Verify single letter data-* key" );
equal( div.data().bigALittleA, "bouncing-b", "Verify single letter mixed data-* key" );
equal( div.data()["wTF"], "ftw", "Verify single letter data-* key" );
equal( div.data()["bigALittleA"], "bouncing-b", "Verify single letter mixed data-* key" );
equal( div.data().foo, "a", "Verify single word data-* key" );
equal( div.data().fooBar, "b", "Verify multiple word data-* key" );
equal( div.data().fooBarBaz, "c", "Verify multiple word data-* key" );
equal( div.data()["foo"], "a", "Verify single word data-* key" );
equal( div.data()["fooBar"], "b", "Verify multiple word data-* key" );
equal( div.data()["fooBarBaz"], "c", "Verify multiple word data-* key" );
equal( div.data("foo"), "a", "Verify single word data-* key" );
equal( div.data("fooBar"), "b", "Verify multiple word data-* key" );
......@@ -627,8 +627,8 @@ test("Triggering the removeData should not throw exceptions. (#10080)", function
test( "Only check element attributes once when calling .data() - #8909", function() {
expect( 2 );
var testing = {
test: "testing",
test2: "testing"
"test": "testing",
"test2": "testing"
},
element = jQuery( "<div data-test='testing'>" ),
node = element[ 0 ];
......
......@@ -39,7 +39,8 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
strictEqual( value , "done" , "Passed function executed" );
});
jQuery.each( "resolve reject".split( " " ), function( _, change ) {
jQuery.expandedEach = jQuery.each;
jQuery.expandedEach( "resolve reject".split( " " ), function( _, change ) {
createDeferred( function( defer ) {
strictEqual( defer.state(), "pending", "pending after creation" );
var checked = 0;
......@@ -60,12 +61,12 @@ jQuery.each( [ "", " - new operator" ], function( _, withNew ) {
test( "jQuery.Deferred - chainability", function() {
var methods = "resolve reject notify resolveWith rejectWith notifyWith done fail progress always".split( " " ),
defer = jQuery.Deferred();
var defer = jQuery.Deferred();
expect( methods.length );
expect( 10 );
jQuery.each( methods, function( _, method ) {
jQuery.expandedEach = jQuery.each;
jQuery.expandedEach( "resolve reject notify resolveWith rejectWith notifyWith done fail progress always".split( " " ), function( _, method ) {
var object = { m: defer[ method ] };
strictEqual( object.m(), object, method + " is chainable" );
});
......
......@@ -38,11 +38,11 @@ var testWidth = function( val ) {
$div.css("border", "2px solid #fff");
equal($div.width(), 0, "Test border specified with pixels");
$div.css({ display: "", border: "", padding: "" });
$div.css({ "display": "", "border": "", "padding": "" });
jQuery("#nothiddendivchild").css({ width: 20, padding: "3px", border: "2px solid #fff" });
jQuery("#nothiddendivchild").css({ "width": 20, "padding": "3px", "border": "2px solid #fff" });
equal(jQuery("#nothiddendivchild").width(), 20, "Test child width with border and padding");
jQuery("#nothiddendiv, #nothiddendivchild").css({ border: "", padding: "", width: "" });
jQuery("#nothiddendiv, #nothiddendivchild").css({ "border": "", "padding": "", "width": "" });
var blah = jQuery("blah");
equal( blah.width( val(10) ), blah, "Make sure that setting a width on an empty set returns the set." );
......@@ -89,11 +89,11 @@ var testHeight = function( val ) {
$div.css("border", "2px solid #fff");
equal($div.height(), 0, "Test border specified with pixels");
$div.css({ display: "", border: "", padding: "", height: "1px" });
$div.css({ "display": "", "border": "", "padding": "", "height": "1px" });
jQuery("#nothiddendivchild").css({ height: 20, padding: "3px", border: "2px solid #fff" });
jQuery("#nothiddendivchild").css({ "height": 20, "padding": "3px", "border": "2px solid #fff" });
equal(jQuery("#nothiddendivchild").height(), 20, "Test child height with border and padding");
jQuery("#nothiddendiv, #nothiddendivchild").css({ border: "", padding: "", height: "" });
jQuery("#nothiddendiv, #nothiddendivchild").css({ "border": "", "padding": "", "height": "" });
var blah = jQuery("blah");
equal( blah.height( val(10) ), blah, "Make sure that setting a height on an empty set returns the set." );
......@@ -136,9 +136,9 @@ test("innerWidth()", function() {
var $div = jQuery("#nothiddendiv");
// set styles
$div.css({
margin: 10,
border: "2px solid #fff",
width: 30
"margin": 10,
"border": "2px solid #fff",
"width": 30
});
equal($div.innerWidth(), 30, "Test with margin and border");
......@@ -148,7 +148,7 @@ test("innerWidth()", function() {
equal($div.innerWidth(), 70, "Test hidden div");
// reset styles
$div.css({ display: "", border: "", padding: "", width: "", height: "" });
$div.css({ "display": "", "border": "", "padding": "", "width": "", "height": "" });
var div = jQuery( "<div>" );
......@@ -171,9 +171,9 @@ test("innerHeight()", function() {
var $div = jQuery("#nothiddendiv");
// set styles
$div.css({
margin: 10,
border: "2px solid #fff",
height: 30
"margin": 10,
"border": "2px solid #fff",
"height": 30
});
equal($div.innerHeight(), 30, "Test with margin and border");
......@@ -183,7 +183,7 @@ test("innerHeight()", function() {
equal($div.innerHeight(), 70, "Test hidden div");
// reset styles
$div.css({ display: "", border: "", padding: "", width: "", height: "" });
$div.css({ "display": "", "border": "", "padding": "", "width": "", "height": "" });
var div = jQuery( "<div>" );
......@@ -221,7 +221,7 @@ test("outerWidth()", function() {
equal($div.outerWidth(true), 94, "Test hidden div with padding, border and margin with margin option");
// reset styles
$div.css({ position: "", display: "", border: "", padding: "", width: "", height: "" });
$div.css({ "position": "", "display": "", "border": "", "padding": "", "width": "", "height": "" });
var div = jQuery( "<div>" );
......@@ -236,7 +236,7 @@ test("child of a hidden elem (or unconnected node) has accurate inner/outer/Widt
expect(16);
// setup html
var $divNormal = jQuery("<div>").css({ width: "100px", height: "100px", border: "10px solid white", padding: "2px", margin: "3px" }),
var $divNormal = jQuery("<div>").css({ "width": "100px", "height": "100px", "border": "10px solid white", "padding": "2px", "margin": "3px" }),
$divChild = $divNormal.clone(),
$divUnconnected = $divNormal.clone(),
$divHiddenParent = jQuery("<div>").css( "display", "none" ).append( $divChild ).appendTo("body");
......@@ -294,7 +294,7 @@ test("getting dimensions shouldnt modify runtimeStyle see #9233", function() {
test("outerWidth(true) returning % instead of px in Webkit, see #10639", function() {
var container = jQuery( "<div/>" ).width(400).appendTo( "#qunit-fixture" ),
el = jQuery( "<div/>" ).css({ width: "50%", marginRight: "50%" }).appendTo( container );
el = jQuery( "<div/>" ).css({ "width": "50%", "marginRight": "50%" }).appendTo( container );
equal( el.outerWidth(true), 400, "outerWidth(true) and css('margin') returning % instead of px in Webkit, see #10639" );
});
......@@ -305,7 +305,7 @@ test( "getting dimensions of zero width/height table elements shouldn't alter di
var table = jQuery("<table><tbody><tr><td></td><td>a</td></tr><tr><td></td><td>a</td></tr></tbody></table>").appendTo("#qunit-fixture"),
elem = table.find("tr:eq(0) td:eq(0)");
table.find("td").css({ margin: 0, padding: 0 });
table.find("td").css({ "margin": 0, "padding": 0 });
equal( elem.width(), elem.width(), "width() doesn't alter dimension values" );
});
......@@ -313,7 +313,7 @@ test("box-sizing:border-box child of a hidden elem (or unconnected node) has acc
expect(16);
// setup html
var $divNormal = jQuery("<div>").css({ boxSizing: "border-box", width: "100px", height: "100px", border: "10px solid white", padding: "2px", margin: "3px" }),
var $divNormal = jQuery("<div>").css({ "boxSizing": "border-box", "width": "100px", "height": "100px", "border": "10px solid white", "padding": "2px", "margin": "3px" }),
$divChild = $divNormal.clone(),
$divUnconnected = $divNormal.clone(),
$divHiddenParent = jQuery("<div>").css( "display", "none" ).append( $divChild ).appendTo("body");
......@@ -373,7 +373,7 @@ test("outerHeight()", function() {
equal($div.outerHeight(true), 94, "Test hidden div with padding, border and margin with margin option");
// reset styles
$div.css({ display: "", border: "", padding: "", width: "", height: "" });
$div.css({ "display": "", "border": "", "padding": "", "width": "", "height": "" });
var div = jQuery( "<div>" );
......
......@@ -199,7 +199,7 @@ test("animate negative height", function() {
test("animate negative margin", function() {
expect(1);
stop();
jQuery("#foo").animate({ marginTop: -100 }, 100, function() {
jQuery("#foo").animate({ "marginTop": -100 }, 100, function() {
equal( jQuery(this).css("marginTop"), "-100px", "Verify margin." );
start();
});
......@@ -217,7 +217,7 @@ test("animate negative margin with px", function() {
test("animate negative padding", function() {
expect(1);
stop();
jQuery("#foo").animate({ paddingBottom: -100 }, 100, function() {
jQuery("#foo").animate({ "paddingBottom": -100 }, 100, function() {
equal( jQuery(this).css("paddingBottom"), "0px", "Verify paddingBottom." );
start();
});
......@@ -559,7 +559,7 @@ test("stop()", function() {
var w = 0;
$foo.hide().css( "width", 200 )
.animate( { width: "show" }, 1000 );
.animate( { "width": "show" }, 1000 );
setTimeout(function() {
var nw = $foo.css("width");
......@@ -598,9 +598,9 @@ test("stop() - several in queue", function() {
var w = 0;
$foo.hide().css( "width", 200 ).css("width");
$foo.animate({ width: "show" }, 1000);
$foo.animate({ width: "hide" }, 1000);
$foo.animate({ width: "show" }, 1000);
$foo.animate({ "width": "show" }, 1000);
$foo.animate({ "width": "hide" }, 1000);
$foo.animate({ "width": "show" }, 1000);
setTimeout(function(){
equal( $foo.queue().length, 3, "All 3 still in the queue" );
var nw = $foo.css("width");
......@@ -623,9 +623,9 @@ test("stop(clearQueue)", function() {
var w = 0;
$foo.hide().css( "width", 200 ).css("width");
$foo.animate({ width: "show" }, 1000);
$foo.animate({ width: "hide" }, 1000);
$foo.animate({ width: "show" }, 1000);
$foo.animate({ "width": "show" }, 1000);
$foo.animate({ "width": "hide" }, 1000);
$foo.animate({ "width": "show" }, 1000);
setTimeout(function(){
var nw = $foo.css("width");
ok( parseFloat( nw ) != w, "An animation occurred " + nw + " " + w + "px");
......@@ -999,6 +999,7 @@ jQuery.fn.saveState = function( hiddenOverflow ) {
});
};
/** @expose */
jQuery.checkState = function() {
var self = this;
jQuery.each(this.save, function( c, v ) {
......@@ -1097,7 +1098,8 @@ test("jQuery.show('fast') doesn't clear radio buttons (bug #1095)", function ()
});
});
jQuery.each({
jQuery.expandedEach = jQuery.each;
jQuery.expandedEach({
"slideToggle": function( $elem ) {
return parseFloat( $elem.css("height") );
},
......@@ -1165,17 +1167,17 @@ test("animate with per-property easing", function(){
c: 100
};
jQuery.easing._test1 = function(p) {
jQuery.easing["_test1"] = function(p) {
_test1_called = true;
return p;
};
jQuery.easing._test2 = function(p) {
jQuery.easing["_test2"] = function(p) {
_test2_called = true;
return p;
};
jQuery.easing._default_test = function(p) {
jQuery.easing["_default_test"] = function(p) {
_default_test_called = true;
return p;
};
......@@ -1198,8 +1200,8 @@ test("animate with CSS shorthand properties", function(){
var _default_count = 0,
_special_count = 0,
propsBasic = { padding: "10 20 30" },
propsSpecial = { padding: [ "1 2 3", "_special" ] };
propsBasic = { "padding": "10 20 30" },
propsSpecial = { "padding": [ "1 2 3", "_special" ] };
jQuery.easing._default = function(p) {
if ( p >= 1 ) {
......@@ -1345,24 +1347,24 @@ test("animate will scale margin properties individually", function() {
stop();
var foo = jQuery( "#foo" ).css({
margin: 0,
marginLeft: 100
"margin": 0,
"marginLeft": 100
});
ok( foo.css( "marginLeft" ) !== foo.css( "marginRight" ), "Sanity Check" );
foo.animate({
margin: 200
"margin": 200
}).stop();
ok( foo.css( "marginLeft") !== foo.css( "marginRight" ), "The margin properties are different");
// clean up for next test
foo.css({
marginLeft: "",
marginRight: "",
marginTop: "",
marginBottom: ""
"marginLeft": '',
"marginRight": '',
"marginTop": '',
"marginBottom": ''
});
start();
});
......@@ -1379,17 +1381,17 @@ test("Do not append px to 'fill-opacity' #9548", 1, function() {
// Start 1.8 Animation tests
asyncTest( "jQuery.Animation( object, props, opts )", 4, function() {
var testObject = {
foo: 0,
bar: 1,
width: 100
"foo": 0,
"bar": 1,
"width": 100
},
testDest = {
foo: 1,
bar: 0,
width: 200
"foo": 1,
"bar": 0,
"width": 200
};
var animation = jQuery.Animation( testObject, testDest, { duration: 1 });
var animation = jQuery.Animation( testObject, testDest, { "duration": 1 });
animation.done(function() {
for ( var prop in testDest ) {
equal( testObject[ prop ], testDest[ prop ], "Animated: " + prop );
......
This diff is collapsed.
......@@ -3,13 +3,13 @@ module("manipulation", { teardown: moduleTeardown });
// Ensure that an extended Array prototype doesn't break jQuery
Array.prototype.arrayProtoFn = function(arg) { throw("arrayProtoFn should not be called"); };
var bareObj = function(value) { return value; };
var functionReturningObj = function(value) { return (function() { return value; }); };
var manipulationBareObj = function(value) { return value; };
var manipulationFunctionReturningObj = function(value) { return (function() { return value; }); };
/*
======== local reference =======
bareObj and functionReturningObj can be used to test passing functions to setters
manipulationBareObj and manipulationFunctionReturningObj can be used to test passing functions to setters
See testVal below for an example
bareObj( value );
......@@ -62,11 +62,11 @@ var testText = function(valueObj) {
};
test("text(String)", function() {
testText(bareObj);
testText(manipulationBareObj);
});
test("text(Function)", function() {
testText(functionReturningObj);
testText(manipulationFunctionReturningObj);
});
test("text(Function) with incoming value", function() {
......@@ -161,11 +161,11 @@ var testWrap = function(val) {
};
test("wrap(String|Element)", function() {
testWrap(bareObj);
testWrap(manipulationBareObj);
});
test("wrap(Function)", function() {
testWrap(functionReturningObj);
testWrap(manipulationFunctionReturningObj);
});
test("wrap(Function) with index (#10177)", function() {
......@@ -217,7 +217,7 @@ var testWrapAll = function(val) {
};
test("wrapAll(String|Element)", function() {
testWrapAll(bareObj);
testWrapAll(manipulationBareObj);
});
var testWrapInner = function(val) {
......@@ -249,11 +249,11 @@ var testWrapInner = function(val) {
};
test("wrapInner(String|Element)", function() {
testWrapInner(bareObj);
testWrapInner(manipulationBareObj);
});
test("wrapInner(Function)", function() {
testWrapInner(functionReturningObj);
testWrapInner(manipulationFunctionReturningObj);
});
test("unwrap()", function() {
......@@ -462,11 +462,11 @@ var testAppend = function(valueObj) {
};
test("append(String|Element|Array&lt;Element&gt;|jQuery)", function() {
testAppend(bareObj);
testAppend(manipulationBareObj);
});
test("append(Function)", function() {
testAppend(functionReturningObj);
testAppend(manipulationFunctionReturningObj);
});
test("append(Function) with incoming value", function() {
......@@ -531,7 +531,7 @@ test("append(Function) with incoming value", function() {
});
test("append the same fragment with events (Bug #6997, 5566)", function () {
var doExtra = !jQuery.support.noCloneEvent && document.fireEvent;
var doExtra = !jQuery.support.noCloneEvent && document["fireEvent"];
expect(2 + (doExtra ? 1 : 0));
stop();
......@@ -783,11 +783,11 @@ var testPrepend = function(val) {
};
test("prepend(String|Element|Array&lt;Element&gt;|jQuery)", function() {
testPrepend(bareObj);
testPrepend(manipulationBareObj);
});
test("prepend(Function)", function() {
testPrepend(functionReturningObj);
testPrepend(manipulationFunctionReturningObj);
});
test("prepend(Function) with incoming value", function() {
......@@ -902,11 +902,11 @@ var testBefore = function(val) {
};
test("before(String|Element|Array&lt;Element&gt;|jQuery)", function() {
testBefore(bareObj);
testBefore(manipulationBareObj);
});
test("before(Function)", function() {
testBefore(functionReturningObj);
testBefore(manipulationFunctionReturningObj);
});
test("before and after w/ empty object (#10812)", function() {
......@@ -971,11 +971,11 @@ var testAfter = function(val) {
};
test("after(String|Element|Array&lt;Element&gt;|jQuery)", function() {
testAfter(bareObj);
testAfter(manipulationBareObj);
});
test("after(Function)", function() {
testAfter(functionReturningObj);
testAfter(manipulationFunctionReturningObj);
});
test("insertAfter(String|Element|Array&lt;Element&gt;|jQuery)", function() {
......@@ -1089,11 +1089,11 @@ var testReplaceWith = function(val) {
};
test("replaceWith(String|Element|Array&lt;Element&gt;|jQuery)", function() {
testReplaceWith(bareObj);
testReplaceWith(manipulationBareObj);
});
test("replaceWith(Function)", function() {
testReplaceWith(functionReturningObj);
testReplaceWith(manipulationFunctionReturningObj);
expect(23);
......@@ -1259,7 +1259,7 @@ test("clone()", function() {
equal( clone.html(), div.html(), "Element contents cloned" );
equal( clone[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
div = jQuery("<div/>").data({ a: true });
div = jQuery("<div/>").data({ "a": true });
clone = div.clone(true);
equal( clone.data("a"), true, "Data cloned." );
clone.data("a", false);
......@@ -1354,7 +1354,7 @@ test("html(undefined)", function() {
var testHtml = function(valueObj) {
expect(35);
jQuery.scriptorder = 0;
jQuery["scriptorder"] = 0;
var div = jQuery("#qunit-fixture > div");
div.html(valueObj("<b>test</b>"));
......@@ -1429,11 +1429,11 @@ var testHtml = function(valueObj) {
};
test("html(String)", function() {
testHtml(bareObj);
testHtml(manipulationBareObj);
});
test("html(Function)", function() {
testHtml(functionReturningObj);
testHtml(manipulationFunctionReturningObj);
expect(37);
......
This diff is collapsed.
......@@ -91,7 +91,7 @@ testIframe("selector/html5_selector", "attributes - jQuery.attr", function( jQue
* @example t("Check for something", "//[a]", ["foo", "baar"]);
* @param {String} a - Assertion name
* @param {String} b - Sizzle selector
* @param {String} c - Array of ids to construct what is expected
* @param {Array} c - Array of ids to construct what is expected
*/
function t( a, b, c ) {
var f = jQuery(b).get(),
......@@ -147,7 +147,8 @@ testIframe("selector/html5_selector", "attributes - jQuery.attr", function( jQue
t( "Attribute Exists", "[truespeed]", ["marquee1"]);
// Enumerated attributes (these are not boolean content attributes)
jQuery.each([ "draggable", "contenteditable", "aria-disabled" ], function( i, val ) {
jQuery.expandedEach = jQuery.each;
jQuery.expandedEach([ "draggable", "contenteditable", "aria-disabled" ], function( i, val ) {
t( "Enumerated attribute", "[" + val + "]", ["div1"]);
});
t( "Enumerated attribute", "[spellcheck]", ["span1"]);
......@@ -157,7 +158,7 @@ testIframe("selector/html5_selector", "attributes - jQuery.attr", function( jQue
});
testIframe("selector/sizzle_cache", "Sizzle cache collides with multiple Sizzles on a page", function( jQuery, window, document ) {
var $cached = window.$cached;
var $cached = window["$cached"];
expect(3);
deepEqual( $cached('.test a').get(), [ document.getElementById('collision') ], "Select collision anchor with first sizzle" );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment