PageSourceSearch

https://www.graphicon.ru/misc/jquery-extend-3.4.0.js?x

js graphicon.ru collected 2026-10-02 07:15:31 UTC 5,251 bytes, 174 lines download raw bytes

1/**
2 * For jQuery versions less than 3.4.0, this replaces the jQuery.extend
3 * function with the one from jQuery 3.4.0, slightly modified (documented
4 * below) to be compatible with older jQuery versions and browsers.
5 *
6 * This provides the Object.prototype pollution vulnerability fix to Drupal
7 * installations running older jQuery versions, including the versions shipped
8 * with Drupal core and https://www.drupal.org/project/jquery_update.
9 *
10 * @see https://github.com/jquery/jquery/pull/4333
11 */
12
13(function (jQuery) {
14
15// Do not override jQuery.extend() if the jQuery version is already >=3.4.0.
16var versionParts = jQuery.fn.jquery.split('.');
17var majorVersion = parseInt(versionParts[0]);
18var minorVersion = parseInt(versionParts[1]);
19var patchVersion = parseInt(versionParts[2]);
20var isPreReleaseVersion = (patchVersion.toString() !== versionParts[2]);
21if (
22  (majorVersion > 3) ||
23  (majorVersion === 3 && minorVersion > 4) ||
24  (majorVersion === 3 && minorVersion === 4 && patchVersion > 0) ||
25  (majorVersion === 3 && minorVersion === 4 && patchVersion === 0 && !isPreReleaseVersion)
26) {
27  return;
28}
29
30/**
31 * This adds some funtions from jQuery 1.4.4 (the default version used in
32 * Drupal 7) for when they aren't present, like when using jQuery 1.2.6 (the
33 * default version used in Drupal 6).
34 */
35
36if (typeof jQuery.type === 'undefined') {
37  var toString = Object.prototype.toString,
38      class2type = {};
39
40  // Populate the class2type map
41  jQuery.each("Boolean Number String Function Array Date RegExp Object".split(" "), function(i, name) {
42    class2type[ "[object " + name + "]" ] = name.toLowerCase();
43  });
44
45  jQuery.type = function (obj) {
46    return obj == null ?
47      String( obj ) :
48      class2type[ toString.call(obj) ] || "object";
49  };
50}
51
52if (typeof jQuery.isArray === 'undefined') {
53  jQuery.isArray = function (obj) {
54    return jQuery.type(obj) === "array";
55  };
56}
57
58if (typeof jQuery.isWindow === 'undefined') {
59  jQuery.isWindow = function (obj) {
60    return obj && typeof obj === "object" && "setInterval" in obj;
61  };
62}
63
64if (typeof jQuery.isPlainObject === 'undefined') {
65  var hasOwn = Object.prototype.hasOwnProperty;
66
67  jQuery.isPlainObject = function (obj) {
68    // Must be an Object.
69    // Because of IE, we also have to check the presence of the constructor property.
70    // Make sure that DOM nodes and window objects don't pass through, as well
71    if ( !obj || jQuery.type(obj) !== "object" || obj.nodeType || jQuery.isWindow( obj ) ) {
72      return false;
73    }
74
75    // Not own constructor property must be Object
76    if ( obj.constructor &&
77      !hasOwn.call(obj, "constructor") &&
78      !hasOwn.call(obj.constructor.prototype, "isPrototypeOf") ) {
79      return false;
80    }
81
82    // Own properties are enumerated firstly, so to speed up,
83    // if last one is own, then all properties are own.
84
85    var key;
86    for ( key in obj ) {}
87
88    return key === undefined || hasOwn.call( obj, key );
89  };
90}
91
92/**
93 * This is almost verbatim copied from jQuery 3.4.0.
94 *
95 * Only two minor changes have been made:
96 * - The call to isFunction() is changed to jQuery.isFunction().
97 * - The two calls to Array.isArray() is changed to jQuery.isArray().
98 *
99 * The above two changes ensure compatibility with all older jQuery versions
100 * (1.2.6 - 3.3.1) and older browser versions (e.g., IE8).
101 */
102jQuery.extend = jQuery.fn.extend = function() {
103  var options, name, src, copy, copyIsArray, clone,
104    target = arguments[ 0 ] || {},
105    i = 1,
106    length = arguments.length,
107    deep = false;
108
109  // Handle a deep copy situation
110  if ( typeof target === "boolean" ) {
111    deep = target;
112
113    // Skip the boolean and the target
114    target = arguments[ i ] || {};
115    i++;
116  }
117
118  // Handle case when target is a string or something (possible in deep copy)
119  if ( typeof target !== "object" && !jQuery.isFunction( target ) ) {
120    target = {};
121  }
122
123  // Extend jQuery itself if only one argument is passed
124  if ( i === length ) {
125    target = this;
126    i--;
127  }
128
129  for ( ; i < length; i++ ) {
130
131    // Only deal with non-null/undefined values
132    if ( ( options = arguments[ i ] ) != null ) {
133
134      // Extend the base object
135      for ( name in options ) {
136        copy = options[ name ];
137
138        // Prevent Object.prototype pollution
139        // Prevent never-ending loop
vendor: 950 bytes, lines 140-174
140        if ( name === "__proto__" || target === copy ) {
141          continue;
142        }
143
144        // Recurse if we're merging plain objects or arrays
145        if ( deep && copy && ( jQuery.isPlainObject( copy ) ||
146          ( copyIsArray = jQuery.isArray( copy ) ) ) ) {
147          src = target[ name ];
148
149          // Ensure proper type for the source value
150          if ( copyIsArray && !jQuery.isArray( src ) ) {
151            clone = [];
152          } else if ( !copyIsArray && !jQuery.isPlainObject( src ) ) {
153            clone = {};
154          } else {
155            clone = src;
156          }
157          copyIsArray = false;
158
159          // Never move original objects, clone them
160          target[ name ] = jQuery.extend( deep, clone, copy );
161
162          // Don't bring in undefined values
163        } else if ( copy !== undefined ) {
164          target[ name ] = copy;
165        }
166      }
167    }
168  }
169
170  // Return the modified object
171  return target;
172};
173
174})(jQuery);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.