Improve oldIE unit tests for fuzzy object clone. Close gh-880.

Related to the patch in gh-870.
This commit is contained in:
Elijah Manor 2012-07-30 13:10:18 -05:00 committed by Dave Methvin
parent 109d910701
commit 488e502b98

View File

@ -1173,7 +1173,8 @@ test("clone() (#8070)", function () {
});
test("clone()", function() {
expect(39);
expect( 44 );
equal( "This is a normal link: Yahoo", jQuery("#en").text(), "Assert text for #en" );
var clone = jQuery("#yahoo").clone();
equal( "Try them out:Yahoo", jQuery("#first").append(clone).text(), "Check for clone" );
@ -1255,7 +1256,32 @@ test("clone()", function() {
clone = div.clone(true);
equal( clone.length, 1, "One element cloned" );
// equal( clone.html(), div.html(), "Element contents cloned" );
(function checkForAttributes( $ ) {
// IE6/7 adds some extra parameters so just test for existance of a defined set
var parameters = ["height", "width", "classid"],
$divObject = div.find("object"),
$cloneObject = clone.find("object");
$.each( parameters, function(index, parameter) {
equal( $cloneObject.attr(parameter), $divObject.attr(parameter), "Element attributes cloned: " + parameter );
});
})( jQuery );
(function checkForParams() {
// IE6/7/8 adds a bunch of extram param elements so just test for those that are trying to clone
var params = {};
clone.find("param").each(function(index, param) {
params[param.attributes.name.nodeValue.toLowerCase()] =
param.attributes.value.nodeValue.toLowerCase();
});
div.find("param").each(function(index, param) {
var actualValue = params[param.attributes.name.nodeValue.toLowerCase()],
expectedValue = param.attributes.value.nodeValue.toLowerCase();
equal( actualValue, expectedValue, "Param cloned: " + param.attributes.name.nodeValue );
});
})();
equal( clone[0].nodeName.toUpperCase(), "DIV", "DIV element cloned" );
// and here's a valid one.