mirror of
https://github.com/jquery/jquery-ui.git
synced 2024-11-21 11:04:24 +00:00
Position: Make sure of
is treated as a CSS selector
Closes gh-1955
This commit is contained in:
parent
32850869d3
commit
effa323f15
@ -113,7 +113,9 @@ QUnit.test( "positions", function( assert ) {
|
|||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( "of", function( assert ) {
|
QUnit.test( "of", function( assert ) {
|
||||||
assert.expect( 9 + ( scrollTopSupport() ? 1 : 0 ) );
|
assert.expect( 10 + ( scrollTopSupport() ? 1 : 0 ) );
|
||||||
|
|
||||||
|
var done = assert.async();
|
||||||
|
|
||||||
var event;
|
var event;
|
||||||
|
|
||||||
@ -225,6 +227,21 @@ QUnit.test( "of", function( assert ) {
|
|||||||
top: 600,
|
top: 600,
|
||||||
left: 400
|
left: 400
|
||||||
}, "event - left top, right bottom" );
|
}, "event - left top, right bottom" );
|
||||||
|
|
||||||
|
try {
|
||||||
|
$( "#elx" ).position( {
|
||||||
|
my: "left top",
|
||||||
|
at: "right bottom",
|
||||||
|
of: "<img onerror='window.globalOf=true' src='/404' />",
|
||||||
|
collision: "none"
|
||||||
|
} );
|
||||||
|
} catch ( e ) {}
|
||||||
|
|
||||||
|
setTimeout( function() {
|
||||||
|
assert.equal( window.globalOf, undefined, "of treated as a selector" );
|
||||||
|
delete window.globalOf;
|
||||||
|
done();
|
||||||
|
}, 500 );
|
||||||
} );
|
} );
|
||||||
|
|
||||||
QUnit.test( "offsets", function( assert ) {
|
QUnit.test( "offsets", function( assert ) {
|
||||||
@ -334,6 +351,7 @@ QUnit.test( "using", function( assert ) {
|
|||||||
assert.deepEqual( position, expectedPosition, "correct position for call #" + count );
|
assert.deepEqual( position, expectedPosition, "correct position for call #" + count );
|
||||||
assert.deepEqual( feedback.element.element[ 0 ], elems[ count ] );
|
assert.deepEqual( feedback.element.element[ 0 ], elems[ count ] );
|
||||||
delete feedback.element.element;
|
delete feedback.element.element;
|
||||||
|
delete feedback.target.element.prevObject;
|
||||||
assert.deepEqual( feedback, expectedFeedback );
|
assert.deepEqual( feedback, expectedFeedback );
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
@ -148,7 +148,12 @@ $.fn.position = function( options ) {
|
|||||||
options = $.extend( {}, options );
|
options = $.extend( {}, options );
|
||||||
|
|
||||||
var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
|
var atOffset, targetWidth, targetHeight, targetOffset, basePosition, dimensions,
|
||||||
target = $( options.of ),
|
|
||||||
|
// Make sure string options are treated as CSS selectors
|
||||||
|
target = typeof options.of === "string" ?
|
||||||
|
$( document ).find( options.of ) :
|
||||||
|
$( options.of ),
|
||||||
|
|
||||||
within = $.position.getWithinInfo( options.within ),
|
within = $.position.getWithinInfo( options.within ),
|
||||||
scrollInfo = $.position.getScrollInfo( within ),
|
scrollInfo = $.position.getScrollInfo( within ),
|
||||||
collision = ( options.collision || "flip" ).split( " " ),
|
collision = ( options.collision || "flip" ).split( " " ),
|
||||||
|
Loading…
Reference in New Issue
Block a user