Skip to content

Commit ecd6a25

Browse files
committed
Core: Removed $.ui.hasScroll(). Fixes #9190 - Core: Remove $.ui.hasScroll().
1 parent b26d207 commit ecd6a25

File tree

2 files changed

+45
-48
lines changed

2 files changed

+45
-48
lines changed

ui/jquery.ui.core.js

Lines changed: 18 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -266,55 +266,29 @@ $.fn.extend({
266266
}
267267
});
268268

269-
$.extend( $.ui, {
270-
// $.ui.plugin is deprecated. Use $.widget() extensions instead.
271-
plugin: {
272-
add: function( module, option, set ) {
273-
var i,
274-
proto = $.ui[ module ].prototype;
275-
for ( i in set ) {
276-
proto.plugins[ i ] = proto.plugins[ i ] || [];
277-
proto.plugins[ i ].push( [ option, set[ i ] ] );
278-
}
279-
},
280-
call: function( instance, name, args ) {
281-
var i,
282-
set = instance.plugins[ name ];
283-
if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
284-
return;
285-
}
286-
287-
for ( i = 0; i < set.length; i++ ) {
288-
if ( instance.options[ set[ i ][ 0 ] ] ) {
289-
set[ i ][ 1 ].apply( instance.element, args );
290-
}
291-
}
269+
// $.ui.plugin is deprecated. Use $.widget() extensions instead.
270+
$.ui.plugin = {
271+
add: function( module, option, set ) {
272+
var i,
273+
proto = $.ui[ module ].prototype;
274+
for ( i in set ) {
275+
proto.plugins[ i ] = proto.plugins[ i ] || [];
276+
proto.plugins[ i ].push( [ option, set[ i ] ] );
292277
}
293278
},
294-
295-
// only used by resizable
296-
hasScroll: function( el, a ) {
297-
298-
//If overflow is hidden, the element might have extra content, but the user wants to hide it
299-
if ( $( el ).css( "overflow" ) === "hidden") {
300-
return false;
279+
call: function( instance, name, args ) {
280+
var i,
281+
set = instance.plugins[ name ];
282+
if ( !set || !instance.element[ 0 ].parentNode || instance.element[ 0 ].parentNode.nodeType === 11 ) {
283+
return;
301284
}
302285

303-
var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
304-
has = false;
305-
306-
if ( el[ scroll ] > 0 ) {
307-
return true;
286+
for ( i = 0; i < set.length; i++ ) {
287+
if ( instance.options[ set[ i ][ 0 ] ] ) {
288+
set[ i ][ 1 ].apply( instance.element, args );
289+
}
308290
}
309-
310-
// TODO: determine which cases actually cause this to happen
311-
// if the element doesn't have the scroll set, see if it's possible to
312-
// set the scroll
313-
el[ scroll ] = 1;
314-
has = ( el[ scroll ] > 0 );
315-
el[ scroll ] = 0;
316-
return has;
317291
}
318-
});
292+
};
319293

320294
})( jQuery );

ui/jquery.ui.resizable.js

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,29 @@ function isNumber(value) {
2323
return !isNaN(parseInt(value, 10));
2424
}
2525

26+
function hasScroll( el, a ) {
27+
28+
//If overflow is hidden, the element might have extra content, but the user wants to hide it
29+
if ( $( el ).css( "overflow" ) === "hidden") {
30+
return false;
31+
}
32+
33+
var scroll = ( a && a === "left" ) ? "scrollLeft" : "scrollTop",
34+
has = false;
35+
36+
if ( el[ scroll ] > 0 ) {
37+
return true;
38+
}
39+
40+
// TODO: determine which cases actually cause this to happen
41+
// if the element doesn't have the scroll set, see if it's possible to
42+
// set the scroll
43+
el[ scroll ] = 1;
44+
has = ( el[ scroll ] > 0 );
45+
el[ scroll ] = 0;
46+
return has;
47+
}
48+
2649
$.widget("ui.resizable", $.ui.mouse, {
2750
version: "@VERSION",
2851
widgetEventPrefix: "resize",
@@ -381,7 +404,7 @@ $.widget("ui.resizable", $.ui.mouse, {
381404

382405
pr = this._proportionallyResizeElements;
383406
ista = pr.length && (/textarea/i).test(pr[0].nodeName);
384-
soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
407+
soffseth = ista && hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height;
385408
soffsetw = ista ? 0 : that.sizeDiff.width;
386409

387410
s = { width: (that.helper.width() - soffsetw), height: (that.helper.height() - soffseth) };
@@ -655,7 +678,7 @@ $.ui.plugin.add("resizable", "animate", {
655678
o = that.options,
656679
pr = that._proportionallyResizeElements,
657680
ista = pr.length && (/textarea/i).test(pr[0].nodeName),
658-
soffseth = ista && $.ui.hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
681+
soffseth = ista && hasScroll(pr[0], "left") /* TODO - jump height */ ? 0 : that.sizeDiff.height,
659682
soffsetw = ista ? 0 : that.sizeDiff.width,
660683
style = { width: (that.size.width - soffsetw), height: (that.size.height - soffseth) },
661684
left = (parseInt(that.element.css("left"), 10) + (that.position.left - that.originalPosition.left)) || null,
@@ -728,8 +751,8 @@ $.ui.plugin.add("resizable", "containment", {
728751
co = that.containerOffset;
729752
ch = that.containerSize.height;
730753
cw = that.containerSize.width;
731-
width = ($.ui.hasScroll(ce, "left") ? ce.scrollWidth : cw );
732-
height = ($.ui.hasScroll(ce) ? ce.scrollHeight : ch);
754+
width = (hasScroll(ce, "left") ? ce.scrollWidth : cw );
755+
height = (hasScroll(ce) ? ce.scrollHeight : ch);
733756

734757
that.parentData = {
735758
element: ce, left: co.left, top: co.top, width: width, height: height

0 commit comments

Comments
 (0)