Skip to content

Commit 9681b1f

Browse files
committed
All: Replaced all uses of $.ui.contains() with $.contains(). Fixes #5000 - Deprecate $.ui.contains.
1 parent 162364f commit 9681b1f

File tree

4 files changed

+15
-20
lines changed

4 files changed

+15
-20
lines changed

ui/jquery.ui.autocomplete.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ $.widget( "ui.autocomplete", {
142142
$( document ).one( 'mousedown', function( event ) {
143143
if ( event.target !== self.element[ 0 ] &&
144144
event.target !== menuElement &&
145-
!$.ui.contains( menuElement, event.target ) ) {
145+
!$.contains( menuElement, event.target ) ) {
146146
self.close();
147147
}
148148
});

ui/jquery.ui.core.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -263,12 +263,7 @@ $.extend( $.ui, {
263263
}
264264
},
265265

266-
// will be deprecated when we switch to jQuery 1.4 - use jQuery.contains()
267-
contains: function( a, b ) {
268-
return document.compareDocumentPosition ?
269-
a.compareDocumentPosition( b ) & 16 :
270-
a !== b && a.contains( b );
271-
},
266+
contains: $.contains,
272267

273268
// only used by resizable
274269
hasScroll: function( el, a ) {

ui/jquery.ui.draggable.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ $.widget("ui.draggable", $.ui.mouse, {
284284
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
285285
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
286286
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
287-
if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
287+
if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
288288
po.left += this.scrollParent.scrollLeft();
289289
po.top += this.scrollParent.scrollTop();
290290
}
@@ -360,7 +360,7 @@ $.widget("ui.draggable", $.ui.mouse, {
360360

361361
if(!pos) pos = this.position;
362362
var mod = d == "absolute" ? 1 : -1;
363-
var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
363+
var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
364364

365365
return {
366366
top: (
@@ -381,7 +381,7 @@ $.widget("ui.draggable", $.ui.mouse, {
381381

382382
_generatePosition: function(event) {
383383

384-
var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
384+
var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
385385
var pageX = event.pageX;
386386
var pageY = event.pageY;
387387

ui/jquery.ui.sortable.js

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -294,8 +294,8 @@ $.widget("ui.sortable", $.ui.mouse, {
294294

295295
if(itemElement != this.currentItem[0] //cannot intersect with itself
296296
&& this.placeholder[intersection == 1 ? "next" : "prev"]()[0] != itemElement //no useless actions that have been done before
297-
&& !$.ui.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
298-
&& (this.options.type == 'semi-dynamic' ? !$.ui.contains(this.element[0], itemElement) : true)
297+
&& !$.contains(this.placeholder[0], itemElement) //no action if the item moved is the parent of the item checked
298+
&& (this.options.type == 'semi-dynamic' ? !$.contains(this.element[0], itemElement) : true)
299299
//&& itemElement.parentNode == this.placeholder[0].parentNode // only rearrange items within the same container
300300
) {
301301

@@ -691,13 +691,13 @@ $.widget("ui.sortable", $.ui.mouse, {
691691
for (var i = this.containers.length - 1; i >= 0; i--){
692692

693693
// never consider a container that's located within the item itself
694-
if($.ui.contains(this.currentItem[0], this.containers[i].element[0]))
694+
if($.contains(this.currentItem[0], this.containers[i].element[0]))
695695
continue;
696696

697697
if(this._intersectsWith(this.containers[i].containerCache)) {
698698

699699
// if we've already found a container and it's more "inner" than this, then continue
700-
if(innermostContainer && $.ui.contains(this.containers[i].element[0], innermostContainer.element[0]))
700+
if(innermostContainer && $.contains(this.containers[i].element[0], innermostContainer.element[0]))
701701
continue;
702702

703703
innermostContainer = this.containers[i];
@@ -725,7 +725,7 @@ $.widget("ui.sortable", $.ui.mouse, {
725725
//When entering a new container, we will find the item with the least distance and append our item near it
726726
var dist = 10000; var itemWithLeastDistance = null; var base = this.positionAbs[this.containers[innermostIndex].floating ? 'left' : 'top'];
727727
for (var j = this.items.length - 1; j >= 0; j--) {
728-
if(!$.ui.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
728+
if(!$.contains(this.containers[innermostIndex].element[0], this.items[j].item[0])) continue;
729729
var cur = this.items[j][this.containers[innermostIndex].floating ? 'left' : 'top'];
730730
if(Math.abs(cur - base) < dist) {
731731
dist = Math.abs(cur - base); itemWithLeastDistance = this.items[j];
@@ -800,7 +800,7 @@ $.widget("ui.sortable", $.ui.mouse, {
800800
// 1. The position of the helper is absolute, so it's position is calculated based on the next positioned parent
801801
// 2. The actual offset parent is a child of the scroll parent, and the scroll parent isn't the document, which means that
802802
// the scroll is included in the initial calculation of the offset of the parent, and never recalculated upon drag
803-
if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) {
803+
if(this.cssPosition == 'absolute' && this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) {
804804
po.left += this.scrollParent.scrollLeft();
805805
po.top += this.scrollParent.scrollTop();
806806
}
@@ -874,7 +874,7 @@ $.widget("ui.sortable", $.ui.mouse, {
874874

875875
if(!pos) pos = this.position;
876876
var mod = d == "absolute" ? 1 : -1;
877-
var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
877+
var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
878878

879879
return {
880880
top: (
@@ -895,7 +895,7 @@ $.widget("ui.sortable", $.ui.mouse, {
895895

896896
_generatePosition: function(event) {
897897

898-
var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.ui.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
898+
var o = this.options, scroll = this.cssPosition == 'absolute' && !(this.scrollParent[0] != document && $.contains(this.scrollParent[0], this.offsetParent[0])) ? this.offsetParent : this.scrollParent, scrollIsRootNode = (/(html|body)/i).test(scroll[0].tagName);
899899

900900
// This is another very weird special case that only happens for relative elements:
901901
// 1. If the css position is relative
@@ -992,10 +992,10 @@ $.widget("ui.sortable", $.ui.mouse, {
992992

993993
if(this.fromOutside && !noPropagation) delayedTriggers.push(function(event) { this._trigger("receive", event, this._uiHash(this.fromOutside)); });
994994
if((this.fromOutside || this.domPosition.prev != this.currentItem.prev().not(".ui-sortable-helper")[0] || this.domPosition.parent != this.currentItem.parent()[0]) && !noPropagation) delayedTriggers.push(function(event) { this._trigger("update", event, this._uiHash()); }); //Trigger update callback if the DOM position has changed
995-
if(!$.ui.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
995+
if(!$.contains(this.element[0], this.currentItem[0])) { //Node was moved out of the current element
996996
if(!noPropagation) delayedTriggers.push(function(event) { this._trigger("remove", event, this._uiHash()); });
997997
for (var i = this.containers.length - 1; i >= 0; i--){
998-
if($.ui.contains(this.containers[i].element[0], this.currentItem[0]) && !noPropagation) {
998+
if($.contains(this.containers[i].element[0], this.currentItem[0]) && !noPropagation) {
999999
delayedTriggers.push((function(c) { return function(event) { c._trigger("receive", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
10001000
delayedTriggers.push((function(c) { return function(event) { c._trigger("update", event, this._uiHash(this)); }; }).call(this, this.containers[i]));
10011001
}

0 commit comments

Comments
 (0)