aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--grunt.js68
-rw-r--r--test/data/testinit.js5
-rw-r--r--test/unit/attributes.js25
-rw-r--r--test/unit/core.js15
-rw-r--r--test/unit/css.js4
-rw-r--r--test/unit/event.js10
-rw-r--r--test/unit/manipulation.js22
-rw-r--r--test/unit/selector.js42
-rw-r--r--test/unit/support.js44
9 files changed, 149 insertions, 86 deletions
diff --git a/grunt.js b/grunt.js
index d3e0c7f6a..062ce837d 100644
--- a/grunt.js
+++ b/grunt.js
@@ -63,14 +63,14 @@ module.exports = function( grunt ) {
"src/selector.js",
"src/traversing.js",
"src/manipulation.js",
- "src/css.js",
+ { flag: "css", src: "src/css.js" },
"src/ajax.js",
"src/ajax/jsonp.js",
"src/ajax/script.js",
"src/ajax/xhr.js",
- { flag: "effects", src: "src/effects.js" },
- { flag: "offset", src: "src/offset.js" },
- { flag: "dimensions", src: "src/dimensions.js" },
+ { flag: "effects", src: "src/effects.js", needs: ["css"] },
+ { flag: "offset", src: "src/offset.js", needs: ["css"] },
+ { flag: "dimensions", src: "src/dimensions.js", needs: ["css"] },
"src/exports.js",
"src/outro.js"
]
@@ -187,28 +187,66 @@ module.exports = function( grunt ) {
"Concatenate source (include/exclude modules with +/- flags), embed date/version",
function() {
// Concat specified files.
- var compiled = "",
- modules = this.flags,
- optIn = !modules["*"],
- name = this.file.dest;
+ var i,
+ compiled = "",
+ modules = this.flags,
+ optIn = !modules["*"],
+ name = this.file.dest,
+ excluded = {},
+ excluder = function( flag, needsFlag ) {
+ // explicit > implicit, so set this first and let it be overridden by explicit
+ if ( optIn && !modules[ flag ] && !modules[ "+" + flag ] ) {
+ excluded[ flag ] = false;
+ }
+ if ( excluded[ needsFlag ] || modules[ "-" + flag ] ) {
+ // explicit exclusion from flag or dependency
+ excluded[ flag ] = true;
+ } else if ( modules[ "+" + flag ] && ( excluded[ needsFlag ] === false ) ) {
+ // explicit inclusion from flag or dependency overriding a weak inclusion
+ delete excluded[ needsFlag ];
+ }
+ };
+
+ // figure out which files to exclude based on these rules in this order:
+ // explicit > implicit (explicit also means a dependency/dependent that was explicit)
+ // exclude > include
+ // examples:
+ // *: none (implicit exclude)
+ // *:* all (implicit include)
+ // *:*:-effects all except effects (explicit > implicit)
+ // *:*:-css all except css and it's deps (explicit)
+ // *:*:-css:+effects all except css and it's deps (explicit exclude from dep. trumps explicit include)
+ // *:+effects none except effects and it's deps (explicit include from dep. trumps implicit exclude)
this.file.src.forEach(function( filepath ) {
- // Include optional modules per build flags; exclusion trumps inclusion
var flag = filepath.flag;
+
if ( flag ) {
- if ( modules[ "-" + flag ] ||
- optIn && !modules[ flag ] && !modules[ "+" + flag ] ) {
- log.writeln( "Excluding " + filepath.flag + ": '" + filepath.src + "'." );
+ excluder(flag);
+
+ // check for dependencies
+ if ( filepath.needs ) {
+ filepath.needs.forEach(function( needsFlag ) {
+ excluder( flag, needsFlag );
+ });
+ }
+ }
+ });
+
+ // conditionally concatenate source
+ this.file.src.forEach(function( filepath ) {
+ var flag = filepath.flag;
+ if ( flag ) {
+ if ( excluded[ flag ] !== undefined ) {
+ log.writeln( "Excluding " + flag + ": '" + filepath.src + "'." );
return;
}
- log.writeln( "Including " + filepath.flag + ": '" + filepath.src + "'." );
+ log.writeln( "Including " + flag + ": '" + filepath.src + "'." );
filepath = filepath.src;
}
- // Unwrap redundant IIFEs
compiled += file.read( filepath );
- //.replace( /^\(function\( jQuery \) \{|\}\)\( jQuery \);\s*$/g, "" );
});
// Embed Date
diff --git a/test/data/testinit.js b/test/data/testinit.js
index f2898e0ba..23bdb9163 100644
--- a/test/data/testinit.js
+++ b/test/data/testinit.js
@@ -198,9 +198,8 @@ function url( value ) {
function loadFixture() {
var src = url("./data/" + fileName + ".html"),
- iframe = jQuery("<iframe />").css({
- width: 500, height: 500, position: "absolute", top: -600, left: -600, visibility: "hidden"
- }).appendTo("body")[0];
+ iframe = jQuery("<iframe />").appendTo("body")[0];
+ iframe.style.cssText = "width: 500px; height: 500px; position: absolute; top: -600px; left: -600px; visibility: hidden;";
iframe.contentWindow.location = src;
return iframe;
}
diff --git a/test/unit/attributes.js b/test/unit/attributes.js
index 33551ba94..6062bc7c9 100644
--- a/test/unit/attributes.js
+++ b/test/unit/attributes.js
@@ -371,10 +371,8 @@ test("attr(jquery_method)", function(){
var $elem = jQuery("<div />"),
elem = $elem[0],
- expected = 5,
- attrObj = {
- css: { paddingLeft: 1, paddingRight: 1 }
- };
+ expected = 2,
+ attrObj = {};
if ( jQuery.fn.width ) {
expected += 2;
@@ -386,6 +384,11 @@ test("attr(jquery_method)", function(){
attrObj.offset = { top: 1, left: 0 };
}
+ if ( jQuery.css ) {
+ expected += 3;
+ attrObj.css = { paddingLeft: 1, paddingRight: 1 };
+ }
+
expect( expected );
// one at a time
@@ -395,9 +398,6 @@ test("attr(jquery_method)", function(){
$elem.attr( { text: "bar" }, true );
equal( elem.innerHTML, "bar", "attr(text)" );
- $elem.attr( { css: { color: "red" } }, true );
- ok( /^(#ff0000|red)$/i.test( elem.style.color ), "attr(css)" );
-
// Multiple attributes
$elem.attr( attrObj, true );
@@ -415,8 +415,13 @@ test("attr(jquery_method)", function(){
equal( elem.style.left, "1px", "attr(offset)" );
}
- equal( elem.style.paddingLeft, "1px", "attr({css:})" );
- equal( elem.style.paddingRight, "1px", "attr({css:})" );
+ if ( jQuery.css ) {
+ equal( elem.style.paddingLeft, "1px", "attr({css:})" );
+ equal( elem.style.paddingRight, "1px", "attr({css:})" );
+
+ $elem.attr( { css: { color: "red" } }, true );
+ ok( /^(#ff0000|red)$/i.test( elem.style.color ), "attr(css)" );
+ }
});
test("attr(String, Object) - Loaded via XML document", function() {
@@ -494,7 +499,7 @@ test("removeAttr(String)", function() {
equal( jQuery("#foo").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute" );
equal( jQuery("#form").attr("style", "position:absolute;").removeAttr("style").attr("style"), undefined, "Check removing style attribute on a form" );
equal( jQuery("<div style='position: absolute'></div>").appendTo("#foo").removeAttr("style").prop("style").cssText, "", "Check removing style attribute (#9699 Webkit)" );
- equal( jQuery("#fx-test-group").attr("height", "3px").removeAttr("height").css("height"), "1px", "Removing height attribute has no effect on height set with style attribute" );
+ equal( jQuery("#fx-test-group").attr("height", "3px").removeAttr("height").get(0).style.height, "1px", "Removing height attribute has no effect on height set with style attribute" );
jQuery("#check1").removeAttr("checked").prop("checked", true).removeAttr("checked");
equal( document.getElementById("check1").checked, false, "removeAttr sets boolean properties to false" );
diff --git a/test/unit/core.js b/test/unit/core.js
index 2daf5d24d..88c470104 100644
--- a/test/unit/core.js
+++ b/test/unit/core.js
@@ -27,9 +27,8 @@ test("jQuery()", function() {
div = jQuery("<div/><hr/><code/><b/>"),
exec = false,
long = "",
- expected = 28,
+ expected = 26,
attrObj = {
- css: { paddingLeft: 1, paddingRight: 1 },
click: function() { ok( exec, "Click executed." ); },
text: "test",
"class": "test2",
@@ -46,6 +45,11 @@ test("jQuery()", function() {
attrObj.offset = { top: 1, left: 1 };
}
+ if ( jQuery.css ) {
+ expected += 2;
+ attrObj.css = { paddingLeft: 1, paddingRight: 1 };
+ }
+
expect( expected );
// Basic constructor's behavior
@@ -103,8 +107,11 @@ test("jQuery()", function() {
equal( elem[0].style.top, "1px", "jQuery() quick setter offset");
}
- equal( elem[0].style.paddingLeft, "1px", "jQuery quick setter css");
- equal( elem[0].style.paddingRight, "1px", "jQuery quick setter css");
+ if ( jQuery.css ) {
+ equal( elem[0].style.paddingLeft, "1px", "jQuery quick setter css");
+ equal( elem[0].style.paddingRight, "1px", "jQuery quick setter css");
+ }
+
equal( elem[0].childNodes.length, 1, "jQuery quick setter text");
equal( elem[0].firstChild.nodeValue, "test", "jQuery quick setter text");
equal( elem[0].className, "test2", "jQuery() quick setter class");
diff --git a/test/unit/css.js b/test/unit/css.js
index b030569fb..ea57c9abe 100644
--- a/test/unit/css.js
+++ b/test/unit/css.js
@@ -1,3 +1,5 @@
+if ( jQuery.css ) {
+
module("css", { teardown: moduleTeardown });
test("css(String|Hash)", function() {
@@ -779,3 +781,5 @@ test( "cssHooks - expand", function() {
});
});
+
+}
diff --git a/test/unit/event.js b/test/unit/event.js
index db7065fd1..36cb53aec 100644
--- a/test/unit/event.js
+++ b/test/unit/event.js
@@ -1020,9 +1020,11 @@ test("trigger(type, [data], [fn])", function() {
// Triggers 5
equal( $elem.triggerHandler("click", [1, "2", "abc"]), "test", "Verify handler response" );
- var pass = true;
+ var pass = true, elem2;
try {
- jQuery("#form input:first").hide().trigger("focus");
+ elem2 = jQuery("#form input:first");
+ elem2.get(0).style.display = "none";
+ elem2.trigger("focus");
} catch(e) {
pass = false;
}
@@ -1133,9 +1135,11 @@ test( "change event bubbles on copied forms (#11796)", function(){
test("trigger(eventObject, [data], [fn])", function() {
expect(28);
- var $parent = jQuery("<div id='par' />").hide().appendTo("body"),
+ var $parent = jQuery("<div id='par' />").appendTo("body"),
$child = jQuery("<p id='child'>foo</p>").appendTo( $parent );
+ $parent.get( 0 ).style.display = "none";
+
var event = jQuery.Event("noNew");
ok( event != window, "Instantiate jQuery.Event without the 'new' keyword" );
equal( event.type, "noNew", "Verify its type" );
diff --git a/test/unit/manipulation.js b/test/unit/manipulation.js
index 0e419a8bb..e8c183f3c 100644
--- a/test/unit/manipulation.js
+++ b/test/unit/manipulation.js
@@ -533,19 +533,21 @@ test("append HTML5 sectioning elements (Bug #6485)", function () {
var article = jQuery("article"),
aside = jQuery("aside");
- equal( article.css("fontSize"), "10px", "HTML5 elements are styleable");
+ equal( article.get( 0 ).style.fontSize, "10px", "HTML5 elements are styleable");
equal( aside.length, 1, "HTML5 elements do not collapse their children")
});
-test("HTML5 Elements inherit styles from style rules (Bug #10501)", function () {
- expect(1);
+if ( jQuery.css ) {
+ test("HTML5 Elements inherit styles from style rules (Bug #10501)", function () {
+ expect(1);
- jQuery("#qunit-fixture").append("<article id='article'></article>");
- jQuery("#article").append("<section>This section should have a pink background.</section>");
+ jQuery("#qunit-fixture").append("<article id='article'></article>");
+ jQuery("#article").append("<section>This section should have a pink background.</section>");
- // In IE, the missing background color will claim its value is "transparent"
- notEqual( jQuery("section").css("background-color"), "transparent", "HTML5 elements inherit styles");
-});
+ // In IE, the missing background color will claim its value is "transparent"
+ notEqual( jQuery("section").css("background-color"), "transparent", "HTML5 elements inherit styles");
+ });
+}
test("html5 clone() cannot use the fragment cache in IE (#6485)", function () {
expect(1);
@@ -1653,8 +1655,8 @@ test("jQuery(<tag>) & wrap[Inner/All]() handle unknown elems (#10667)", function
$wraptarget.wrapAll("<aside style='background-color:green'></aside>");
- notEqual( $wraptarget.parent("aside").css("background-color"), "transparent", "HTML5 elements created with wrapAll inherit styles" );
- notEqual( $section.css("background-color"), "transparent", "HTML5 elements create with jQuery( string ) inherit styles" );
+ notEqual( $wraptarget.parent("aside").get( 0 ).style.backgroundColor, "transparent", "HTML5 elements created with wrapAll inherit styles" );
+ notEqual( $section.get( 0 ).style.backgroundColor, "transparent", "HTML5 elements create with jQuery( string ) inherit styles" );
});
test("Cloned, detached HTML5 elems (#10667,10670)", function() {
diff --git a/test/unit/selector.js b/test/unit/selector.js
index f4a5f4954..5bea3215e 100644
--- a/test/unit/selector.js
+++ b/test/unit/selector.js
@@ -34,26 +34,28 @@ test("attributes - jQuery only", function() {
t( "Find elements with a tabindex attribute", "[tabindex]", ["listWithTabIndex", "foodWithNegativeTabIndex", "linkWithTabIndex", "linkWithNegativeTabIndex", "linkWithNoHrefWithTabIndex", "linkWithNoHrefWithNegativeTabIndex"] );
});
-test("pseudo - visibility", function() {
- expect( 9 );
-
- t( "Is Visible", "div:visible:not(#qunit-testrunner-toolbar):lt(2)", ["nothiddendiv", "nothiddendivchild"] );
- t( "Is Not Hidden", "#qunit-fixture:hidden", [] );
- t( "Is Hidden", "#form input:hidden", ["hidden1","hidden2"] );
-
- var $div = jQuery('<div/>').appendTo("body");
- $div.css({ fontSize: 0, lineHeight: 0 });// IE also needs to set font-size and line-height to 0
- $div.css( "width", 1 ).css( "height", 0 );
- t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
- t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
- $div.css( "width", 0 ).css( "height", 1 );
- t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
- t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
- $div.css( "width", 1 ).css( "height", 1 );
- t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
- t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
- $div.remove();
-});
+if ( jQuery.css ) {
+ test("pseudo - visibility", function() {
+ expect( 9 );
+
+ t( "Is Visible", "div:visible:not(#qunit-testrunner-toolbar):lt(2)", ["nothiddendiv", "nothiddendivchild"] );
+ t( "Is Not Hidden", "#qunit-fixture:hidden", [] );
+ t( "Is Hidden", "#form input:hidden", ["hidden1","hidden2"] );
+
+ var $div = jQuery('<div/>').appendTo("body");
+ $div.css({ fontSize: 0, lineHeight: 0 });// IE also needs to set font-size and line-height to 0
+ $div.css( "width", 1 ).css( "height", 0 );
+ t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
+ t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
+ $div.css( "width", 0 ).css( "height", 1 );
+ t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
+ t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
+ $div.css( "width", 1 ).css( "height", 1 );
+ t( "Is Visible", '#nothiddendivchild:visible', ['nothiddendivchild'] );
+ t( "Is Not Visible", '#nothiddendivchild:hidden', [] );
+ $div.remove();
+ });
+}
test("disconnected nodes", function() {
expect( 4 );
diff --git a/test/unit/support.js b/test/unit/support.js
index bb4887921..e733d520d 100644
--- a/test/unit/support.js
+++ b/test/unit/support.js
@@ -6,30 +6,32 @@ test("boxModel", function() {
equal( jQuery.support.boxModel, document.compatMode === "CSS1Compat" , "jQuery.support.boxModel is sort of tied to quirks mode but unstable since 1.8" );
});
-testIframeWithCallback( "body background is not lost if set prior to loading jQuery (#9238)", "support/bodyBackground", function( color, support ) {
- expect( 2 );
- var i,
- passed = true,
- okValue = {
- "#000000": true,
- "rgb(0, 0, 0)": true
- };
- ok( okValue[ color ], "color was not reset (" + color + ")" );
+if ( jQuery.css ) {
+ testIframeWithCallback( "body background is not lost if set prior to loading jQuery (#9238)", "support/bodyBackground", function( color, support ) {
+ expect( 2 );
+ var i,
+ passed = true,
+ okValue = {
+ "#000000": true,
+ "rgb(0, 0, 0)": true
+ };
+ ok( okValue[ color ], "color was not reset (" + color + ")" );
- for ( i in jQuery.support ) {
- if ( jQuery.support[ i ] !== support[ i ] ) {
- passed = false;
- strictEqual( jQuery.support[ i ], support[ i ], "Support property " + i + " is different" );
+ for ( i in jQuery.support ) {
+ if ( jQuery.support[ i ] !== support[ i ] ) {
+ passed = false;
+ strictEqual( jQuery.support[ i ], support[ i ], "Support property " + i + " is different" );
+ }
}
- }
- for ( i in support ) {
- if ( !( i in jQuery.support ) ) {
- passed = false;
- strictEqual( jQuery.support[ i ], support[ i ], "Unexpected property: " + i );
+ for ( i in support ) {
+ if ( !( i in jQuery.support ) ) {
+ passed = false;
+ strictEqual( jQuery.support[ i ], support[ i ], "Unexpected property: " + i );
+ }
}
- }
- ok( passed, "Same support properties" );
-});
+ ok( passed, "Same support properties" );
+ });
+}
testIframeWithCallback( "A background on the testElement does not cause IE8 to crash (#9823)", "support/testElementCrash", function() {
expect(1);