-/* for testing opacity set in styles in IE */
ol#empty {
opacity: 0;
}
$first = jQuery("<div Case='mixed'></div>");
equal( $first.attr("Case"), "mixed", "case of attribute doesn't matter" );
$first.removeAttr("Case");
- // IE 6/7 return empty string here, not undefined
- ok( !$first.attr("Case"), "mixed-case attribute was removed" );
+ equal( $first.attr( "Case" ), undefined, "mixed-case attribute was removed" );
});
test( "removeAttr(String) in XML", function() {
// Firefox says this is a function
ok( !jQuery.isFunction(obj), "Object Element" );
- // IE says this is an object
// Since 1.3, this isn't supported (#2968)
//ok( jQuery.isFunction(obj.getAttribute), "getAttribute Function" );
input.type = "text";
document.body.appendChild( input );
- // IE says this is an object
// Since 1.3, this isn't supported (#2968)
//ok( jQuery.isFunction(input.focus), "A default function property" );
var $p = jQuery("<p>").appendTo("#qunit-fixture");
- if ( "widows" in $p[0].style ) {
- expect(4);
- $p.css({
- "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
- });
+ expect( 4 );
+ $p.css({
+ "widows": 0,
+ "orphans": 0
+ });
- equal( $p.css("widows") || jQuery.style( $p[0], "widows" ), 3, "widows correctly set to 3");
- equal( $p.css("orphans") || jQuery.style( $p[0], "orphans" ), 3, "orphans correctly set to 3");
- } else {
+ 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" );
- expect(1);
- ok( true, "jQuery does not attempt to test for style props that definitely don't exist in older versions of IE");
- }
+ $p.css({
+ "widows": 3,
+ "orphans": 3
+ });
+ equal( $p.css( "widows" ) || jQuery.style( $p[0], "widows" ), 3, "widows correctly set to 3" );
+ equal( $p.css( "orphans" ) || jQuery.style( $p[0], "orphans" ), 3, "orphans correctly set to 3" );
$p.remove();
});
}
});
-test("percentage properties for bottom and right in IE<9 should not be incorrectly transformed to pixels, see #11311", function() {
- expect( 1 );
- var div = jQuery("<div style='position: absolute; width: 1px; height: 20px; bottom:50%;'></div>").appendTo( "#qunit-fixture" );
- ok( window.getComputedStyle || div.css( "bottom" ) === "50%", "position properties get incorrectly transformed in IE<8, see #11311" );
-});
-
if ( jQuery.fn.offset ) {
test("percentage properties for left and top should be transformed to pixels, see #9505", function() {
expect( 2 );
test("animate table-row width/height", function() {
expect(3);
stop();
- var displayMode,
- tr = jQuery("#table")
+ var tr = jQuery( "#table" )
.attr({ "cellspacing": 0, "cellpadding": 0, "border": 0 })
- .html("<tr style='height:42px;'><td style='padding:0;'><div style='width:20px;height:20px;'></div></td></tr>")
- .find("tr");
-
- // IE<8 uses "block" instead of the correct display type
- displayMode = tr.css("display") !== "table-row" ? "block" : "table-row";
+ .html( "<tr style='height:42px;'><td style='padding:0;'><div style='width:20px;height:20px;'></div></td></tr>" )
+ .find( "tr" );
tr.animate({ width: 10, height: 10 }, 100, function() {
- equal( jQuery(this).css("display"), displayMode, "display mode is correct" );
+ equal( jQuery( this ).css( "display" ), "table-row", "display mode is correct" );
equal( this.offsetWidth, 20, "width animated to shrink wrap point" );
equal( this.offsetHeight, 20, "height animated to shrink wrap point" );
start();
test("animate table-cell width/height", function() {
expect(3);
stop();
- var displayMode,
- td = jQuery("#table")
+ var td = jQuery( "#table" )
.attr({ "cellspacing": 0, "cellpadding": 0, "border": 0 })
- .html("<tr><td style='width:42px;height:42px;padding:0;'><div style='width:20px;height:20px;'></div></td></tr>")
- .find("td");
-
- // IE<8 uses "block" instead of the correct display type
- displayMode = td.css("display") !== "table-cell" ? "block" : "table-cell";
+ .html( "<tr><td style='width:42px;height:42px;padding:0;'><div style='width:20px;height:20px;'></div></td></tr>" )
+ .find( "td" );
td.animate({ width: 10, height: 10 }, 100, function() {
- equal( jQuery(this).css("display"), displayMode, "display mode is correct" );
+ equal( jQuery( this ).css( "display" ), "table-cell", "display mode is correct" );
equal( this.offsetWidth, 20, "width animated to shrink wrap point" );
equal( this.offsetHeight, 20, "height animated to shrink wrap point" );
start();
f_o = f( elem, "opacity" );
}
- // The only time an _empty_string_ will be matched is in IE
- // otherwise, the correct values will be tested as usual
- if ( f_o === "" ) {
- f_o = 1;
- }
- // See above
- if ( cur_o === "" ) {
- cur_o = 1;
- }
-
if ( t_o === "hide" || t_o === "show" ) {
equal( cur_o, f_o, "Opacity must be reset to " + f_o + ": " + cur_o );
}
$main = jQuery( "#qunit-fixture" ),
fakeClick = function($jq) {
// Use a native click so we don't get jQuery simulated bubbling
- if ( document.createEvent ) {
- var e = document.createEvent( "MouseEvents" );
- e.initEvent( "click", true, true );
- $jq[0].dispatchEvent(e);
- }
- else if ( $jq[0].click ) {
- $jq[0].click(); // IE
- }
+ var e = document.createEvent( "MouseEvents" );
+ e.initEvent( "click", true, true );
+ $jq[ 0 ].dispatchEvent( e );
};
$anchor2.on( "click", function(e) {
e.preventDefault();
});
- $main.on("click", "#foo", function(e) {
- var orig = e.originalEvent;
-
- if ( typeof(orig.defaultPrevented) === "boolean" || typeof(orig.returnValue) === "boolean" || orig["getPreventDefault"] ) {
- equal( e.isDefaultPrevented(), true, "isDefaultPrevented true passed to bubbled event" );
-
- } else {
- // Opera < 11 doesn't implement any interface we can use, so give it a pass
- ok( true, "isDefaultPrevented not supported by this browser, test skipped" );
- }
+ $main.on( "click", "#foo", function( e ) {
+ equal( e.isDefaultPrevented(), true, "isDefaultPrevented true passed to bubbled event" );
});
fakeClick( $anchor2 );
$anchor2.off( "click" );
equal( event.isDefaultPrevented(), false, "default not prevented" );
});
-// Explicitly introduce global variable for oldIE so QUnit doesn't complain if checking globals
-window.onclick = undefined;
test(".trigger() bubbling on disconnected elements (#10489)", function() {
expect(2);
equal( jQuery( j[ 0 ] ).text(), "hi!", "Check node,textnode,comment with text()" );
equal( j[ 1 ].nodeValue, " there ", "Check node,textnode,comment with text()" );
- // Blackberry 4.6 doesn't maintain comments in the DOM
- equal( jQuery("#nonnodes")[ 0 ].childNodes.length < 3 ? 8 : j[ 2 ].nodeType, 8, "Check node,textnode,comment with text()" );
+ equal( j[ 2 ].nodeType, 8, "Check node,textnode,comment with text()" );
// Update multiple elements #11809
expected = "New";
testIframe("offset/relative", "relative", function( $ ) {
expect(60);
- var ie, tests;
-
- // IE is collapsing the top margin of 1px; detect and adjust accordingly
- ie = $("#relative-1").offset().top === 6;
-
// get offset
- tests = [
- { "id": "#relative-1", "top": ie ? 6 : 7, "left": 7 },
- { "id": "#relative-1-1", "top": ie ? 13 : 15, "left": 15 },
- { "id": "#relative-2", "top": ie ? 141 : 142, "left": 27 }
+ var tests = [
+ { "id": "#relative-1", "top": 7, "left": 7 },
+ { "id": "#relative-1-1", "top": 15, "left": 15 },
+ { "id": "#relative-2", "top": 142, "left": 27 }
];
jQuery.each( tests, function() {
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
// get position
tests = [
- { "id": "#relative-1", "top": ie ? 5 : 6, "left": 6 },
- { "id": "#relative-1-1", "top": ie ? 4 : 5, "left": 5 },
- { "id": "#relative-2", "top": ie ? 140 : 141, "left": 26 }
+ { "id": "#relative-1", "top": 6, "left": 6 },
+ { "id": "#relative-1-1", "top": 5, "left": 5 },
+ { "id": "#relative-2", "top": 141, "left": 26 }
];
jQuery.each( tests, function() {
equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["id"] + "').position().top" );
testIframe("offset/static", "static", function( $ ) {
expect( 80 );
- var ie, tests;
-
- // IE is collapsing the top margin of 1px; detect and adjust accordingly
- ie = $("#static-1").offset().top === 6;
-
// get offset
- tests = [
- { "id": "#static-1", "top": ie ? 6 : 7, "left": 7 },
- { "id": "#static-1-1", "top": ie ? 13 : 15, "left": 15 },
- { "id": "#static-1-1-1", "top": ie ? 20 : 23, "left": 23 },
- { "id": "#static-2", "top": ie ? 121 : 122, left: 7 }
+ var tests = [
+ { "id": "#static-1", "top": 7, "left": 7 },
+ { "id": "#static-1-1", "top": 15, "left": 15 },
+ { "id": "#static-1-1-1", "top": 23, "left": 23 },
+ { "id": "#static-2", "top": 122, left: 7 }
];
jQuery.each( tests, function() {
equal( $( this["id"] ).offset().top, this["top"], "jQuery('" + this["id"] + "').offset().top" );
// get position
tests = [
- { "id": "#static-1", "top": ie ? 5 : 6, "left": 6 },
- { "id": "#static-1-1", "top": ie ? 12 : 14, "left": 14 },
- { "id": "#static-1-1-1", "top": ie ? 19 : 22, "left": 22 },
- { "id": "#static-2", "top": ie ? 120 : 121, "left": 6 }
+ { "id": "#static-1", "top": 6, "left": 6 },
+ { "id": "#static-1-1", "top": 14, "left": 14 },
+ { "id": "#static-1-1-1", "top": 22, "left": 22 },
+ { "id": "#static-2", "top": 121, "left": 6 }
];
jQuery.each( tests, function() {
equal( $( this["id"] ).position().top, this["top"], "jQuery('" + this["top"] + "').position().top" );
testIframe("offset/fixed", "fixed", function( $ ) {
expect(34);
- var ie, tests, $noTopLeft;
-
- // IE is collapsing the top margin of 1px; detect and adjust accordingly
- ie = $("#fixed-1").position().top === 2;
+ var tests, $noTopLeft;
tests = [
{
"id": "#fixed-1",
"offsetTop": 1001,
"offsetLeft": 1001,
- "positionTop": ie ? 2 : 0,
- "positionLeft": ie ? 2 : 0
+ "positionTop": 0,
+ "positionLeft": 0
},
{
"id": "#fixed-2",
"offsetTop": 1021,
"offsetLeft": 1021,
- "positionTop": ie ? 22 : 20,
- "positionLeft": ie ? 22 : 20
+ "positionTop": 20,
+ "positionLeft": 20
}
];
testIframe("offset/scroll", "scroll", function( $, win ) {
expect(24);
- // If we're going to bastardize the tests, let's just DO it
- var ie = /msie [678]/i.test( navigator.userAgent );
-
- if ( ie ) {
- ok( true, "TestSwarm's iframe has hosed this test in oldIE, we surrender" );
- } else {
- equal( $("#scroll-1").offset().top, 7, "jQuery('#scroll-1').offset().top" );
- }
+ equal( $("#scroll-1").offset().top, 7, "jQuery('#scroll-1').offset().top" );
equal( $("#scroll-1").offset().left, 7, "jQuery('#scroll-1').offset().left" );
- if ( ie ) {
- ok( true, "TestSwarm's iframe has hosed this test in oldIE, we surrender" );
- } else {
- equal( $("#scroll-1-1").offset().top, 11, "jQuery('#scroll-1-1').offset().top" );
- }
+ equal( $("#scroll-1-1").offset().top, 11, "jQuery('#scroll-1-1').offset().top" );
equal( $("#scroll-1-1").offset().left, 11, "jQuery('#scroll-1-1').offset().left" );
// scroll offset tests .scrollTop/Left
});
testIframe("selector/html5_selector", "attributes - jQuery.attr", function( jQuery, window, document ) {
- expect( 35 );
+ expect( 38 );
/**
* Returns an array of elements with the given IDs
t( "Attribute Exists", "[indeterminate]", []);
t( "Attribute Exists", "[ismap]", ["img1"]);
t( "Attribute Exists", "[itemscope]", ["div1"]);
- // t( "Attribute Exists", "[loop]", ["video1"]); // IE 6/7 cannot differentiate here. loop is also used on img, input, and marquee tags as well as video/audio. getAttributeNode unfortunately also retrieves the property value.
+ t( "Attribute Exists", "[loop]", ["video1"]);
t( "Attribute Exists", "[multiple]", ["select1"]);
t( "Attribute Exists", "[muted]", ["audio1"]);
- // t( "Attribute Exists", "[nohref]", ["area1"]); // IE 6/7 keep this set to false regardless of presence. The attribute node is not retrievable.
+ t( "Attribute Exists", "[nohref]", ["area1"]);
t( "Attribute Exists", "[noresize]", ["textarea1"]);
t( "Attribute Exists", "[noshade]", ["hr1"]);
t( "Attribute Exists", "[nowrap]", ["td1", "div1"]);
});
t( "Enumerated attribute", "[spellcheck]", ["span1"]);
- // t( "tabindex selector does not retrieve all elements in IE6/7(#8473)", "form, [tabindex]", ["form1", "text1"] ); // sigh, FF12 QSA mistakenly includes video elements even though they have no tabindex attribute (see https://bugzilla.mozilla.org/show_bug.cgi?id=618737)
+ t( "tabindex selector does not retrieve all elements in IE6/7 (#8473)",
+ "form, [tabindex]", [ "form1", "text1" ] );
t( "Improperly named form elements do not interfere with form selections (#9570)", "form[name='formName']", ["form1"] );
});
j = jQuery("#nonnodes").contents();
j.wrap( val("<i></i>") );
- // Blackberry 4.6 doesn't maintain comments in the DOM
equal( jQuery("#nonnodes > i").length, jQuery("#nonnodes")[ 0 ].childNodes.length, "Check node,textnode,comment wraps ok" );
equal( jQuery("#nonnodes > i").text(), j.text(), "Check node,textnode,comment wraps doesn't hurt text" );