Unverified Commit 8a40e427 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3183149 by nod_, droplet, jptaranto: Deprecate jquery.once and use the new once lib

parent 286129f8
Loading
Loading
Loading
Loading
+15 −13
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ drupal.ajax:
    - core/drupal
    - core/drupalSettings
    - core/drupal.progress
    - core/jquery.once
    - core/once
    - core/tabbable

drupal.announce:
@@ -154,7 +154,7 @@ drupal.batch:
    - core/drupalSettings
    - core/drupal.ajax
    - core/drupal.progress
    - core/jquery.once
    - core/once

drupal.checkbox:
  version: VERSION
@@ -174,7 +174,7 @@ drupal.collapse:
    - core/modernizr
    - core/drupal
    - core/drupal.form
    - core/jquery.once
    - core/once

drupal.date:
  version: VERSION
@@ -280,7 +280,7 @@ drupal.dropbutton:
    - core/jquery
    - core/drupal
    - core/drupalSettings
    - core/jquery.once
    - core/once

drupal.element.closest:
  version: VERSION
@@ -309,7 +309,7 @@ drupal.form:
    - core/jquery
    - core/drupal
    - core/drupal.debounce
    - core/jquery.once
    - core/once

drupal.machine-name:
  version: VERSION
@@ -317,7 +317,7 @@ drupal.machine-name:
    misc/machine-name.js: {}
  dependencies:
    - core/jquery
    - core/jquery.once
    - core/once
    - core/drupal
    - core/drupalSettings
    - core/drupal.form
@@ -357,7 +357,7 @@ drupal.states:
    - core/jquery
    - core/drupal
    - core/drupalSettings
    - core/jquery.once
    - core/once

drupal.tabbingmanager:
  version: VERSION
@@ -376,7 +376,7 @@ drupal.tabledrag:
    - core/jquery
    - core/drupal
    - core/drupalSettings
    - core/jquery.once
    - core/once

drupal.tableheader:
  version: VERSION
@@ -386,7 +386,7 @@ drupal.tableheader:
    - core/jquery
    - core/drupal
    - core/drupalSettings
    - core/jquery.once
    - core/once
    - core/drupal.displace

drupal.tableresponsive:
@@ -396,7 +396,7 @@ drupal.tableresponsive:
  dependencies:
    - core/jquery
    - core/drupal
    - core/jquery.once
    - core/once

drupal.tableselect:
  version: VERSION
@@ -406,7 +406,7 @@ drupal.tableselect:
    - core/drupal
    - core/drupal.checkbox
    - core/jquery
    - core/jquery.once
    - core/once

drupal.timezone:
  version: VERSION
@@ -414,7 +414,7 @@ drupal.timezone:
    misc/timezone.js: {}
  dependencies:
    - core/jquery
    - core/jquery.once
    - core/once
    - core/drupal

drupal.vertical-tabs:
@@ -427,7 +427,7 @@ drupal.vertical-tabs:
      misc/vertical-tabs.css: {}
  dependencies:
    - core/jquery
    - core/jquery.once
    - core/once
    - core/drupal
    - core/drupalSettings
    - core/drupal.form
@@ -529,6 +529,7 @@ jquery.once:
  dependencies:
    - core/jquery
    - core/jquery.once.bc
  deprecated: The %library_id% asset library is deprecated in Drupal 9.3.0 and will be removed in Drupal 10.0.0. Use the core/once library instead. See https://www.drupal.org/node/3158256

jquery.once.bc:
  version: VERSION
@@ -849,6 +850,7 @@ drupal.dialog.off_canvas:
      misc/dialog/off-canvas.layout.css: {}
  dependencies:
    - core/jquery
    - core/once
    - core/drupal
    - core/drupal.ajax
    - core/drupal.announce
+48 −53
Original line number Diff line number Diff line
@@ -32,10 +32,10 @@
        if (typeof elementSettings.selector === 'undefined') {
          elementSettings.selector = `#${base}`;
        }
        $(elementSettings.selector)
          .once('drupal-ajax')
          .each(function () {
            elementSettings.element = this;
        // Use jQuery selector instead of a native selector for
        // backwards compatibility.
        once('drupal-ajax', $(elementSettings.selector)).forEach((el) => {
          elementSettings.element = el;
          elementSettings.base = base;
          Drupal.ajax(elementSettings);
        });
@@ -49,14 +49,12 @@
      Drupal.ajax.bindAjaxLinks(document.body);

      // This class means to submit the form to the action using Ajax.
      $('.use-ajax-submit')
        .once('ajax')
        .each(function () {
      once('ajax', '.use-ajax-submit').forEach((el) => {
        const elementSettings = {};

        // Ajax submits specified in this manner automatically submit to the
        // normal form action.
          elementSettings.url = $(this.form).attr('action');
        elementSettings.url = $(el.form).attr('action');
        // Form submit button clicks need to tell the form what was clicked so
        // it gets passed in the POST request.
        elementSettings.setClick = true;
@@ -65,8 +63,8 @@
        // Clicked form buttons look better with the throbber than the progress
        // bar.
        elementSettings.progress = { type: 'throbber' };
          elementSettings.base = $(this).attr('id');
          elementSettings.element = this;
        elementSettings.base = el.id;
        elementSettings.element = el;

        Drupal.ajax(elementSettings);
      });
@@ -289,10 +287,7 @@
   */
  Drupal.ajax.bindAjaxLinks = (element) => {
    // Bind Ajax behaviors to all items showing the class.
    $(element)
      .find('.use-ajax')
      .once('ajax')
      .each((i, ajaxLink) => {
    once('ajax', '.use-ajax', element).forEach((ajaxLink) => {
      const $linkElement = $(ajaxLink);

      const elementSettings = {
@@ -306,8 +301,8 @@
      };
      const href = $linkElement.attr('href');
      /**
         * For anchor tags, these will go to the target of the anchor rather
         * than the usual location.
       * For anchor tags, these will go to the target of the anchor rather than
       * the usual location.
       */
      if (href) {
        elementSettings.url = href;
+7 −7
Original line number Diff line number Diff line
@@ -29,8 +29,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
          elementSettings.selector = "#".concat(base);
        }

        $(elementSettings.selector).once('drupal-ajax').each(function () {
          elementSettings.element = this;
        once('drupal-ajax', $(elementSettings.selector)).forEach(function (el) {
          elementSettings.element = el;
          elementSettings.base = base;
          Drupal.ajax(elementSettings);
        });
@@ -40,16 +40,16 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
        return loadAjaxBehavior(base);
      });
      Drupal.ajax.bindAjaxLinks(document.body);
      $('.use-ajax-submit').once('ajax').each(function () {
      once('ajax', '.use-ajax-submit').forEach(function (el) {
        var elementSettings = {};
        elementSettings.url = $(this.form).attr('action');
        elementSettings.url = $(el.form).attr('action');
        elementSettings.setClick = true;
        elementSettings.event = 'click';
        elementSettings.progress = {
          type: 'throbber'
        };
        elementSettings.base = $(this).attr('id');
        elementSettings.element = this;
        elementSettings.base = el.id;
        elementSettings.element = el;
        Drupal.ajax(elementSettings);
      });
    },
@@ -139,7 +139,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
  };

  Drupal.ajax.bindAjaxLinks = function (element) {
    $(element).find('.use-ajax').once('ajax').each(function (i, ajaxLink) {
    once('ajax', '.use-ajax', element).forEach(function (ajaxLink) {
      var $linkElement = $(ajaxLink);
      var elementSettings = {
        progress: {
+6 −7
Original line number Diff line number Diff line
@@ -212,9 +212,9 @@
  Drupal.behaviors.autocomplete = {
    attach(context) {
      // Act on textfields with the "form-autocomplete" class.
      const $autocomplete = $(context)
        .find('input.form-autocomplete')
        .once('autocomplete');
      const $autocomplete = $(
        once('autocomplete', 'input.form-autocomplete', context),
      );
      if ($autocomplete.length) {
        // Allow options to be overridden per instance.
        const blacklist = $autocomplete.attr(
@@ -240,10 +240,9 @@
    },
    detach(context, settings, trigger) {
      if (trigger === 'unload') {
        $(context)
          .find('input.form-autocomplete')
          .removeOnce('autocomplete')
          .autocomplete('destroy');
        $(
          once.remove('autocomplete', 'input.form-autocomplete', context),
        ).autocomplete('destroy');
      }
    },
  };
+2 −2
Original line number Diff line number Diff line
@@ -116,7 +116,7 @@

  Drupal.behaviors.autocomplete = {
    attach: function attach(context) {
      var $autocomplete = $(context).find('input.form-autocomplete').once('autocomplete');
      var $autocomplete = $(once('autocomplete', 'input.form-autocomplete', context));

      if ($autocomplete.length) {
        var blacklist = $autocomplete.attr('data-autocomplete-first-character-blacklist');
@@ -136,7 +136,7 @@
    },
    detach: function detach(context, settings, trigger) {
      if (trigger === 'unload') {
        $(context).find('input.form-autocomplete').removeOnce('autocomplete').autocomplete('destroy');
        $(once.remove('autocomplete', 'input.form-autocomplete', context)).autocomplete('destroy');
      }
    }
  };
Loading