PageSourceSearch

https://www.nestlehealthscience.com.hk/modules/custom/nhsc_jquery_compat/js/jquery4-compat-shims.js?v=4.0.0

js nestlehealthscience.com.hk collected 2026-10-06 07:59:01 UTC 2,973 bytes, 81 lines download raw bytes

1/**
2 * @file
3 * Shims for jQuery 4.0 removals that jQuery Migrate 3.x does NOT restore.
4 *
5 * Loaded immediately after jquery-migrate.min.js (and jquery.min.js).
6 *
7 * jQuery.camelCase():
8 *   jQuery 4.0 removed jQuery.camelCase(). jQuery Migrate 3.6 registers its
9 *   camelCase patch by wrapping the *original* jQuery.camelCase, which is now
10 *   undefined — so any call to $.camelCase() throws:
11 *     "TypeError: Cannot read properties of undefined (reading 'apply')"
12 *   (jquery-migrate.js:183). Owl Carousel 2 and Bootstrap 3 (collapse.js) both
13 *   call $.camelCase(), which broke the carousels and the bootstrap-toggle
14 *   plugin registration. We install a working implementation here, after
15 *   Migrate, so it overrides Migrate's broken wrapper.
16 */
17(function (jQuery) {
18  'use strict';
19
20  if (!jQuery) {
21    return;
22  }
23
24  // Bootstrap 3.x version guard:
25  //   bootstrap.min.js refuses to run on jQuery >= 4 and THROWS at load
26  //   ("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but
27  //   lower than version 4"), which aborts the entire Bootstrap bundle —
28  //   collapse/accordion, dropdowns, modals, the drupal/bootstrap Dialog
29  //   bridge, etc. jQuery Migrate supplies the real API compatibility, so we
30  //   spoof the reported version string to a 3.x value to let Bootstrap 3
31  //   initialise. (This only affects code that reads $.fn.jquery for version
32  //   detection; Migrate has already run its own checks before this point.)
33  if (jQuery.fn && typeof jQuery.fn.jquery === 'string' &&
34      parseInt(jQuery.fn.jquery, 10) >= 4) {
35    jQuery.fn.jquery = '3.7.1';
36  }
37
38  // Matches jQuery's historical camelCase implementation.
39  var rmsPrefix = /^-ms-/;
40  var rdashAlpha = /-([a-z])/g;
41
42  function fcamelCase(all, letter) {
43    return letter.toUpperCase();
44  }
45
46  jQuery.camelCase = function (string) {
47    return string.replace(rmsPrefix, 'ms-').replace(rdashAlpha, fcamelCase);
48  };
49
50  // jQuery 4.0 removed $.cssNumber. jQuery Migrate 3.x's css-number patch
51  // accesses $.cssNumber[propertyName] when $.fn.css() is called with a numeric
52  // value — for example, jQuery UI widgets set .css('zIndex', 90) during dialog
53  // creation (_setupHandles). Without this, the access throws:
54  //   "TypeError: Cannot read properties of undefined (reading 'zIndex')"
55  // which aborts the openDialog AJAX command and prevents off-canvas/modal
56  // dialogs from opening.
57  if (!jQuery.cssNumber) {
58    jQuery.cssNumber = {
59      animationIterationCount: true,
60      columnCount: true,
61      fillOpacity: true,
62      flexGrow: true,
63      flexShrink: true,
64      fontWeight: true,
65      gridArea: true,
66      gridColumn: true,
67      gridColumnEnd: true,
68      gridColumnStart: true,
69      gridRow: true,
70      gridRowEnd: true,
71      gridRowStart: true,
72      lineHeight: true,
73      opacity: true,
74      order: true,
75      orphans: true,
76      widows: true,
77      zIndex: true,
78      zoom: true,
79    };
80  }
81})(window.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.