Unverified Commit 68081082 authored by Lauri Timmanee's avatar Lauri Timmanee
Browse files

Issue #3239134 by hooroomoo, bnjmnm, yogeshmpawar, nod_, Theresa.Grannum,...

Issue #3239134 by hooroomoo, bnjmnm, yogeshmpawar, nod_, Theresa.Grannum, larowlan: Refactor (if feasible) uses of the jQuery val function to use VanillaJS
parent 440bcc05
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@
    "jquery/no-toggle": 0,
    "jquery/no-trigger": 0,
    "jquery/no-trim": 2,
    "jquery/no-val": 0,
    "jquery/no-val": 2,
    "jquery/no-when": 0,
    "jquery/no-wrap": 0
  }
+2 −0
Original line number Diff line number Diff line
@@ -311,6 +311,7 @@ drupal.ajax:
    - core/jquery
    - core/drupal
    - core/drupalSettings
    - core/drupal.nodelist.foreach
    - core/drupal.progress
    - core/once
    - core/jquery.once.bc
@@ -677,6 +678,7 @@ drupal.timezone:
  js:
    misc/timezone.js: {}
  dependencies:
    - core/drupal.nodelist.foreach
    - core/jquery
    - core/once
    - core/jquery.once.bc
+7 −3
Original line number Diff line number Diff line
@@ -1570,9 +1570,13 @@
     *   The XMLHttpRequest status.
     */
    update_build_id(ajax, response, status) {
      $(`input[name="form_build_id"][value="${response.old}"]`).val(
        response.new,
      );
      document
        .querySelectorAll(
          `input[name="form_build_id"][value="${response.old}"]`,
        )
        .forEach((item) => {
          item.value = response.new;
        });
    },

    /**
+3 −1
Original line number Diff line number Diff line
@@ -647,7 +647,9 @@
    },

    update_build_id(ajax, response, status) {
      $(`input[name="form_build_id"][value="${response.old}"]`).val(response.new);
      document.querySelectorAll(`input[name="form_build_id"][value="${response.old}"]`).forEach(item => {
        item.value = response.new;
      });
    },

    add_css(ajax, response, status) {
+11 −6
Original line number Diff line number Diff line
@@ -245,11 +245,16 @@
        userInfo.forEach((info) => {
          const $element = $forms.find(`[name=${info}]`);
          const browserData = localStorage.getItem(`Drupal.visitor.${info}`);
          const emptyOrDefault =
            $element.val() === '' ||
            $element.attr('data-drupal-default-value') === $element.val();
          if ($element.length && emptyOrDefault && browserData) {
            $element.val(browserData);
          if (!$element.length) {
            return;
          }
          const emptyValue = $element[0].value === '';
          const defaultValue =
            $element.attr('data-drupal-default-value') === $element[0].value;
          if (browserData && (emptyValue || defaultValue)) {
            $element.each(function (index, item) {
              item.value = browserData;
            });
          }
        });
      }
@@ -257,7 +262,7 @@
        userInfo.forEach((info) => {
          const $element = $forms.find(`[name=${info}]`);
          if ($element.length) {
            localStorage.setItem(`Drupal.visitor.${info}`, $element.val());
            localStorage.setItem(`Drupal.visitor.${info}`, $element[0].value);
          }
        });
      });
Loading