Deprecated t.isFunction Call on D11.1

Created on 1 March 2025, 3 months ago

Problem/Motivation

On Drupal 11.1 waypoints failes with the error:

EDGE:

drupal.js?v=11.1.3:64  Uncaught TypeError: t.isFunction is not a function
    at T.waypoint (jquery.waypoints.min.js?v=4.0.1:7:8494)
    at waypoints-animations-init.js?v=11.1.3:8:38
    at Array.forEach (<anonymous>)
    at Object.attach (waypoints-animations-init.js?v=11.1.3:4:93)
    at drupal.js?v=11.1.3:166:24
    at Array.forEach (<anonymous>)
    at Object.attachBehaviors (drupal.js?v=11.1.3:162:34)
    at drupal.init.js?v=11.1.3:32:12
    at HTMLDocument.listener (drupal.init.js?v=11.1.3:20:7)
(anonymous) @ jquery.waypoints.min.js?v=4.0.1:7
(anonymous) @ waypoints-animations-init.js?v=11.1.3:8
attach @ waypoints-animations-init.js?v=11.1.3:4
(anonymous) @ drupal.js?v=11.1.3:166
(anonymous) @ drupal.js?v=11.1.3:162
(anonymous) @ drupal.init.js?v=11.1.3:32
listener @ drupal.init.js?v=11.1.3:20

FireFox:

    t jQuery
    attach https://testsvr/themes/custom/baseplus/js/init/waypoints-animations-init.js?v=11.1.3:8
    attach https://testsvr/themes/custom/baseplus/js/init/waypoints-animations-init.js?v=11.1.3:4
    attachBehaviors https://testsvr/core/misc/drupal.js?v=11.1.3:166
    attachBehaviors https://testsvr/core/misc/drupal.js?v=11.1.3:162
    <anonymous> https://testsvr/core/misc/drupal.init.js?v=11.1.3:32
    listener https://testsvr/core/misc/drupal.init.js?v=11.1.3:20
    domReady https://testsvr/core/misc/drupal.init.js?v=11.1.3:26
    <anonymous> https://testsvr/core/misc/drupal.init.js?v=11.1.3:31
    <anonymous> https://testsvr/core/misc/drupal.init.js?v=11.1.3:34
jquery.waypoints.min.js:7:8494
    t jQuery
    attach https://testsvr/themes/custom/baseplus/js/init/waypoints-animations-init.js?v=11.1.3:8
    forEach self-hosted:157
    attach https://testsvr/themes/custom/baseplus/js/init/waypoints-animations-init.js?v=11.1.3:4
    attachBehaviors https://testsvr/core/misc/drupal.js?v=11.1.3:166
    forEach self-hosted:157
    attachBehaviors https://testsvr/core/misc/drupal.js?v=11.1.3:162
    <anonymous> https://testsvr/core/misc/drupal.init.js?v=11.1.3:32
    listener https://testsvr/core/misc/drupal.init.js?v=11.1.3:20
    (Async: EventListener.handleEvent)
    domReady https://testsvr/core/misc/drupal.init.js?v=11.1.3:26
    <anonymous> https://testsvr/core/misc/drupal.init.js?v=11.1.3:31
    <anonymous> https://testsvr/core/misc/drupal.init.js?v=11.1.3:34

As of jQuery 3.3, jQuery.isFunction() has been deprecated. In most cases, its use can be replaced by typeof x === "function".

jquery.waypoints.min.js is still using this function call.

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

2.1

Component

Code

Created by

🇦🇹Austria maxilein

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

  • Issue created by @maxilein
  • Status changed to Closed: works as designed about 1 month ago
  • 🇷🇸Serbia levmyshkin Novi Sad, Serbia

    What’s blowing up?
    Drupal 11 ships with jQuery 4.0.0-beta. One of the breaking changes in jQuery 4 is that the long-deprecated helper jQuery.isFunction() (and the alias $.isFunction) has been removed. The minified Waypoints 4.0.1 library that your theme/module loads still calls that helper. In the compressed file the call appears as t.isFunction, where t is the local reference to jQuery. Because the method no longer exists, the browser throws:
    Uncaught TypeError: t.isFunction is not a function

    right where Waypoints tries to register a waypoint.

    Fix options:

    1. Patch Waypoints (recommended)
    Replace every occurence of $.isFunction(…) with typeof … === 'function'

    2. Add a one-line polyfill Before Waypoints loads, inject js
    js if (typeof jQuery.isFunction !== 'function') { jQuery.isFunction = obj => typeof obj === 'function'; }

    3. Use jQuery Migrate 4 plugin Load the official migrate plugin that re-adds removed helpers.

    Quick Drupal-specific patch
    Create my_module/js/jquery4-polyfills.js:

    /**
     * Tiny polyfills for libraries that still expect jQuery < 4.
     */
    (( $, Drupal, drupalSettings ) => {
      if (typeof $.isFunction !== 'function') {
        $.isFunction = obj => typeof obj === 'function';
      }
    })(jQuery, Drupal, drupalSettings);
    

    Then add this library to your theme/modules’ libraries.yml before the Waypoints library to guarantee it is evaluated first.

    Long-term
    Track the “Deprecated t.isFunction call on D11” issue in the jQuery Waypoints queue; once a new release lands, remove your patch/polyfill.
    Drupal

    Audit any other contributed or custom scripts for calls to $.isFunction, $.isNumeric, $.trim, jQuery.type, etc.—all of them vanished in jQuery 4. Drupal’s upgrade status report will flag many of these automatically.
    Drupal

    Once Waypoints (and any similar libraries) are patched, Drupal 11 + jQuery 4 will run without the “isFunction” crash.

Production build 0.71.5 2024