diff options
author | Shashanka Nataraj <shashankan.10@gmail.com> | 2017-06-23 04:14:43 +0000 |
---|---|---|
committer | Timmy Willison <4timmywil@gmail.com> | 2017-07-10 12:00:27 -0400 |
commit | c18d608537d8945de6c5855a9475657177fa74ac (patch) | |
tree | 1d1dee3376abc5218d3c0da26f540003d9b70f05 /src | |
parent | 490db839fb08a9b461e77dbe0138c7e6045aacd8 (diff) | |
download | jquery-c18d608537d8945de6c5855a9475657177fa74ac.tar.gz jquery-c18d608537d8945de6c5855a9475657177fa74ac.zip |
Core: Deprecate jQuery.isWindow
Fixes gh-3629
Close gh-3702
Diffstat (limited to 'src')
-rw-r--r-- | src/core.js | 9 | ||||
-rw-r--r-- | src/deprecated.js | 6 | ||||
-rw-r--r-- | src/dimensions.js | 5 | ||||
-rw-r--r-- | src/event/trigger.js | 8 | ||||
-rw-r--r-- | src/offset.js | 6 | ||||
-rw-r--r-- | src/var/isWindow.js | 8 |
6 files changed, 25 insertions, 17 deletions
diff --git a/src/core.js b/src/core.js index ce43d737e..fc538a49a 100644 --- a/src/core.js +++ b/src/core.js @@ -16,10 +16,11 @@ define( [ "./var/fnToString", "./var/ObjectFunctionString", "./var/support", + "./var/isWindow", "./core/DOMEval" ], function( arr, document, getProto, slice, concat, push, indexOf, class2type, toString, hasOwn, fnToString, ObjectFunctionString, - support, DOMEval ) { + support, isWindow, DOMEval ) { "use strict"; @@ -220,10 +221,6 @@ jQuery.extend( { return typeof obj === "function" && typeof obj.nodeType !== "number"; }, - isWindow: function( obj ) { - return obj != null && obj === obj.window; - }, - isNumeric: function( obj ) { // As of jQuery 3.0, isNumeric is limited to @@ -469,7 +466,7 @@ function isArrayLike( obj ) { var length = !!obj && "length" in obj && obj.length, type = jQuery.type( obj ); - if ( jQuery.isFunction( obj ) || jQuery.isWindow( obj ) ) { + if ( jQuery.isFunction( obj ) || isWindow( obj ) ) { return false; } diff --git a/src/deprecated.js b/src/deprecated.js index 9589ec872..3ae78aac8 100644 --- a/src/deprecated.js +++ b/src/deprecated.js @@ -1,7 +1,8 @@ define( [ "./core", - "./core/nodeName" -], function( jQuery, nodeName ) { + "./core/nodeName", + "./var/isWindow" +], function( jQuery, nodeName, isWindow ) { "use strict"; @@ -36,5 +37,6 @@ jQuery.holdReady = function( hold ) { jQuery.isArray = Array.isArray; jQuery.parseJSON = JSON.parse; jQuery.nodeName = nodeName; +jQuery.isWindow = isWindow; } ); diff --git a/src/dimensions.js b/src/dimensions.js index 46e7b1c46..2a2c0391d 100644 --- a/src/dimensions.js +++ b/src/dimensions.js @@ -1,8 +1,9 @@ define( [ "./core", "./core/access", + "./var/isWindow", "./css" -], function( jQuery, access ) { +], function( jQuery, access, isWindow ) { "use strict"; @@ -19,7 +20,7 @@ jQuery.each( { Height: "height", Width: "width" }, function( name, type ) { return access( this, function( elem, type, value ) { var doc; - if ( jQuery.isWindow( elem ) ) { + if ( isWindow( elem ) ) { // $( window ).outerWidth/Height return w/h including scrollbars (gh-1729) return funcName.indexOf( "outer" ) === 0 ? diff --git a/src/event/trigger.js b/src/event/trigger.js index c3b048026..1ecda7d68 100644 --- a/src/event/trigger.js +++ b/src/event/trigger.js @@ -4,9 +4,9 @@ define( [ "../data/var/dataPriv", "../data/var/acceptData", "../var/hasOwn", - + "../var/isWindow", "../event" -], function( jQuery, document, dataPriv, acceptData, hasOwn ) { +], function( jQuery, document, dataPriv, acceptData, hasOwn, isWindow ) { "use strict"; @@ -76,7 +76,7 @@ jQuery.extend( jQuery.event, { // Determine event propagation path in advance, per W3C events spec (#9951) // Bubble up to document, then to window; watch for a global ownerDocument var (#9724) - if ( !onlyHandlers && !special.noBubble && !jQuery.isWindow( elem ) ) { + if ( !onlyHandlers && !special.noBubble && !isWindow( elem ) ) { bubbleType = special.delegateType || type; if ( !rfocusMorph.test( bubbleType + type ) ) { @@ -128,7 +128,7 @@ jQuery.extend( jQuery.event, { // Call a native DOM method on the target with the same name as the event. // Don't do default actions on window, that's where global variables be (#6170) - if ( ontype && jQuery.isFunction( elem[ type ] ) && !jQuery.isWindow( elem ) ) { + if ( ontype && jQuery.isFunction( elem[ type ] ) && !isWindow( elem ) ) { // Don't re-trigger an onFOO event when we call its FOO() method tmp = elem[ ontype ]; diff --git a/src/offset.js b/src/offset.js index 563c6e8cd..f1d64d6a2 100644 --- a/src/offset.js +++ b/src/offset.js @@ -7,12 +7,12 @@ define( [ "./css/curCSS", "./css/addGetHookIf", "./css/support", - + "./var/isWindow", "./core/init", "./css", "./selector" // contains ], function( jQuery, access, document, documentElement, rnumnonpx, - curCSS, addGetHookIf, support ) { + curCSS, addGetHookIf, support, isWindow ) { "use strict"; @@ -186,7 +186,7 @@ jQuery.each( { scrollLeft: "pageXOffset", scrollTop: "pageYOffset" }, function( // Coalesce documents and windows var win; - if ( jQuery.isWindow( elem ) ) { + if ( isWindow( elem ) ) { win = elem; } else if ( elem.nodeType === 9 ) { win = elem.defaultView; diff --git a/src/var/isWindow.js b/src/var/isWindow.js new file mode 100644 index 000000000..2ba1168dd --- /dev/null +++ b/src/var/isWindow.js @@ -0,0 +1,8 @@ +define( function() { + "use strict"; + + return function isWindow( obj ) { + return obj != null && obj === obj.window; + }; + +} ); |