(function() { if ( !jQuery.fn.wrap ) { // no wrap module return; } module( "wrap", { teardown: moduleTeardown }); // See test/unit/manipulation.js for explanation about these 2 functions function manipulationBareObj( value ) { return value; } function manipulationFunctionReturningObj( value ) { return function() { return value; }; } function testWrap( val ) { expect( 19 ); var defaultText, result, j, i, cacheLength; defaultText = "Try them out:"; result = jQuery("#first").wrap( val("
") ).text(); equal( defaultText, result, "Check for wrapping of on-the-fly html" ); ok( jQuery("#first").parent().parent().is(".red"), "Check if wrapper has class 'red'" ); result = jQuery("#first").wrap( val(document.getElementById("empty")) ).parent(); ok( result.is("ol"), "Check for element wrapping" ); equal( result.text(), defaultText, "Check for element wrapping" ); jQuery("#check1").on( "click", function() { var checkbox = this; ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" ); jQuery( checkbox ).wrap( val("") ); ok( checkbox.checked, "Checkbox's state is erased after wrap() action, see #769" ); }).prop( "checked", false )[ 0 ].click(); // using contents will get comments regular, text, and comment nodes j = jQuery("#nonnodes").contents(); j.wrap( val("") ); equal( jQuery("#nonnodes > i").length, 3, "Check node,textnode,comment wraps ok" ); equal( jQuery("#nonnodes > i").text(), j.text(), "Check node,textnode,comment wraps doesn't hurt text" ); // Try wrapping a disconnected node cacheLength = 0; for ( i in jQuery.cache ) { cacheLength++; } j = jQuery("