mirror of
https://github.com/jquery/jquery.git
synced 2024-10-05 11:34:18 +00:00
Fix #12283. Return null for dimension getters on non elements. Fix gh-900.
This commit is contained in:
parent
9f86dc922e
commit
ad040181dc
@ -35,7 +35,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) {
|
|||||||
|
|
||||||
// Set width or height on the element
|
// Set width or height on the element
|
||||||
jQuery.style( elem, type, value, extra );
|
jQuery.style( elem, type, value, extra );
|
||||||
}, type, chainable ? margin : undefined, chainable );
|
}, type, chainable ? margin : undefined, chainable, null );
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -385,6 +385,22 @@ test("passing undefined is a setter #5571", function() {
|
|||||||
equal(jQuery("#nothiddendiv").width(30).width(undefined).width(), 30, ".width(undefined) is chainable (#5571)");
|
equal(jQuery("#nothiddendiv").width(30).width(undefined).width(), 30, ".width(undefined) is chainable (#5571)");
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test( "getters on non elements should return null", function() {
|
||||||
|
expect( 8 );
|
||||||
|
|
||||||
|
var nonElem = jQuery("notAnElement");
|
||||||
|
|
||||||
|
strictEqual( nonElem.width(), null, ".width() is not null (#12283)" );
|
||||||
|
strictEqual( nonElem.innerWidth(), null, ".innerWidth() is not null (#12283)" );
|
||||||
|
strictEqual( nonElem.outerWidth(), null, ".outerWidth() is not null (#12283)" );
|
||||||
|
strictEqual( nonElem.outerWidth( true ), null, ".outerWidth(true) is not null (#12283)" );
|
||||||
|
|
||||||
|
strictEqual( nonElem.height(), null, ".height() is not null (#12283)" );
|
||||||
|
strictEqual( nonElem.innerHeight(), null, ".innerHeight() is not null (#12283)" );
|
||||||
|
strictEqual( nonElem.outerHeight(), null, ".outerHeight() is not null (#12283)" );
|
||||||
|
strictEqual( nonElem.outerHeight( true ), null, ".outerHeight(true) is not null (#12283)" );
|
||||||
|
});
|
||||||
|
|
||||||
test("setters with and without box-sizing:border-box", function(){
|
test("setters with and without box-sizing:border-box", function(){
|
||||||
expect(20);
|
expect(20);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user