Verified Commit 8ac73be3 authored by Théodore Biadala's avatar Théodore Biadala
Browse files

Issue #3238868 by ahsannazir, smustgrave: Refactor some uses of the jQuery...

Issue #3238868 by ahsannazir, smustgrave: Refactor some uses of the jQuery parents function to use vanillaJS
parent eceeb8f6
Loading
Loading
Loading
Loading
Loading
+12 −11
Original line number Diff line number Diff line
@@ -1377,17 +1377,18 @@
        $newContent[effect.showEffect](effect.showSpeed);
      }

      // Attach all JavaScript behaviors to the new content, if it was
      // successfully added to the page, this if statement allows
      // `#ajax['wrapper']` to be optional.
      if ($newContent.parents('html').length) {
      // Attach behaviors to all element nodes.
      $newContent.each((index, element) => {
          if (element.nodeType === Node.ELEMENT_NODE) {
        if (
          element.nodeType === Node.ELEMENT_NODE &&
          // Attach all JavaScript behaviors to the new content, if it was
          // successfully added to the page, this condition allows
          // `#ajax['wrapper']` to be optional.
          document.documentElement.contains(element)
        ) {
          Drupal.attachBehaviors(element, settings);
        }
      });
      }
    },

    /**
+1 −1
Original line number Diff line number Diff line
@@ -241,7 +241,7 @@
          $this.on('change.editorAttach', { field }, onTextFormatChange);
        }
        // Detach any editor when the containing form is submitted.
        $this.parents('form').on('submit', (event) => {
        $(field.form).on('submit', (event) => {
          // Do not detach if the event was canceled.
          if (event.isDefaultPrevented()) {
            return;
+5 −5
Original line number Diff line number Diff line
@@ -160,15 +160,15 @@
       * set active editable ID.
       */
      .forEach((instance) => {
        const closestSettingsTray = instance.element.closest(
          '.settings-tray-editable',
        );
        // Check to make sure existing dialogOptions aren't overridden.
        if (!instance.options.data.hasOwnProperty('dialogOptions')) {
          instance.options.data.dialogOptions = {};
        }
        instance.options.data.dialogOptions.settingsTrayActiveEditableId = $(
          instance.element,
        )
          .parents('.settings-tray-editable')
          .attr('id');
        instance.options.data.dialogOptions.settingsTrayActiveEditableId =
          closestSettingsTray.id;
        instance.progress = { type: 'fullscreen' };
      });
  }