jQuery 2.0 added native-API selector module.

What's out:
6 KB
attribute not equal selector
positional selectors (:first; :eq(n); :odd; etc.)
type selectors (:input; :checkbox; :button; etc.)
state-based selectors (:animated; :visible; :hidden; etc.)
:has(selector)
custom selectors
leading combinators (e.g., $collection.find("> *"))
reliable functionality on XML fragments
requiring all parts of a selector to match elements under context (e.g., $div.find("div > *") now matches children of $div)
matching against non-elements
reliable sorting of disconnected nodes

https://github.com/jquery/jquery/pull/1180

What actually we can do ?

Here is one cleanup example:
https://github.com/jquery/jquery/commit/59f5adb622dd6bc3419bbaa9cc2d4acd...

Real benefit in Drupal:
http://drupal.org/node/1880798

Comments

nod_’s picture

droplet’s picture

Issue tags: +Novice, +js-novice

Tagging novice.

most of this cleanup are search & replace jobs. Sadly, I don't have time to run through of it recently. Anyone would like to take this task ?

don't hesitate to contact me if you need helps.

Here is an example:
search: :checkbox
replace: [type="checkbox"]

droplet’s picture

kool.

Let me start from simple one:
#1937924: Remove jQuery deprecated function

littledynamo’s picture

Assigned: Unassigned » littledynamo
littledynamo’s picture

Assigned: littledynamo » Unassigned
Jelle_S’s picture

Questions:

  • Should this be a meta issue and should we create separate issues for each module (cfr selectors-cleanup)?
  • Should this be part of the selectors-cleanup issues (since a lot of them are marked fixed / closed(fixed) )?
  • If the answer to both questions is no (meaning we will do all of this in one go) should we wait for all selectors-cleanup issues to be fixed?
nod_’s picture

No plan yet. I'm guessing 1. is the way to go. The selector cleanup was to remove crazy things. Making them mean and lean is another story.

Jelle_S’s picture

Title: Make CORE compatible with jQuery native-API selector » [META] Make CORE compatible with jQuery native-API selector
droplet’s picture

If we have reviewer and committer REAL supports. i will have a look at it soon. All JS fixes given me very bad experience. for example: #1793648: Follow-up: replace all occurence of Drupal.settings with drupalSettings, 9 months for a search & replace patch.

Separate issue per module is a very bad idea because most of clean up need not to do manually tests.

Look at jQuery example:
https://github.com/jquery/jquery/pull/1180

It is not a crazy change. :)

Jelle_S’s picture

Just FYI:

This probably covers most (probably not all though!) of what needs to be changed (grep -rn "('[^']*:[^']*'" --include=*.js . and then manually removed non-relevant lines from that output)

./core/misc/ajax.js:203:      if (this.form.find(':file').length) {
./core/misc/ajax.js:708:    $(response.selector).find('> tbody > tr:visible, > tr:visible')
./core/misc/dialog.ajax.js:32:          $context.find('input:first').focus();
./core/misc/machine-name.js:84:        if ($target.is(':disabled') || $target.val() !== '') {
./core/misc/machine-name.js:99:        if ($target.is(':disabled')) {
./core/misc/tabledrag.js:198:      cell = cells.filter(':nth-child(' + index + ')');
./core/misc/tabledrag.js:313:  $item.find('td:first a').addClass('menu-item__link');
./core/misc/tabledrag.js:317:  var $indentationLast = $item.find('td:first .indentation:last');
./core/misc/tabledrag.js:324:    $item.find('td:first').prepend(handle);
./core/misc/tabledrag.js:419:        var $nextRow = $(self.rowObject.group).filter(':last').next('tr').eq(0);
./core/misc/tabledrag.js:438:              var nextGroupRow = $(nextGroup.group).filter(':last').get(0);
./core/misc/tabledrag.js:806:      sourceRow = $(this.table).find('tr.draggable:first').get(0);
./core/misc/tabledrag.js:928:  $(this.table).find('> tbody > tr.draggable:visible, > tr.draggable:visible')
./core/misc/tabledrag.js:1024:    $(rows[rows.length - 1]).find('.indentation:nth-child(' + (parentIndentation + 1) + ')').addClass('tree-child-last');
./core/misc/tabledrag.js:1131:    var nextRow = $group.filter(':last').next('tr').get(0);
./core/misc/tabledrag.js:1144:      $group.find('.indentation:first').remove();
./core/misc/tabledrag.js:1148:      $group.find('td:first').prepend(Drupal.theme('tableDragIndentation'));
./core/misc/tabledrag.js:1228:  var cell = $(this.element).find('td:first');
./core/misc/tableresponsive.js:92:          var $cells = $(this).find('td:eq(' + position + ')');
./core/misc/vertical-tabs.js:58:      $(tab_list).find('> li:first').addClass('first');
./core/misc/vertical-tabs.js:59:      $(tab_list).find('> li:last').addClass('last');
./core/misc/vertical-tabs.js:69:          tab_focus = $this.find('> .vertical-tabs-pane:first');
./core/misc/vertical-tabs.js:157:      .filter(':visible:first').addClass('first');
./core/misc/vertical-tabs.js:175:      .filter(':visible:first').addClass('first');
./core/misc/vertical-tabs.js:179:    var $firstTab = this.details.siblings('.vertical-tabs-pane:not(.vertical-tab-hidden):first');
./core/modules/block/custom_block/custom_block.js:21:      if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $context.find('.form-item-log textarea').length)) {
./core/modules/block/custom_block/custom_block.js:34:        translate = $checkbox.is(':checked') ? Drupal.t('Needs to be updated') : Drupal.t('Does not need to be updated');
./core/modules/block/custom_block/custom_block.js:38:        translate = $checkbox.is(':checked') ? Drupal.t('Flag other translations as outdated') : Drupal.t('Do not flag other translations as outdated');
./core/modules/ckeditor/js/ckeditor.admin.js:54:        var $targetButton = $destinationRow.children(':eq(' + destinationPosition + ')');
./core/modules/content_translation/content_translation.admin.js:68:      if (!$input.is(':checked')) {
./core/modules/content_translation/content_translation.admin.js:84:      if ($target.is(':checked')) {
./core/modules/content_translation/content_translation.admin.js:96:      if ($target.is(':checked')) {
./core/modules/contextual/js/contextual.js:40:    title: $region.find('h2:first').text().trim()
./core/modules/contextual/js/contextual.js:286:          .find('.contextual .trigger:not(:first)')
./core/modules/edit/js/editors/directEditor.js:24:    var $textElement = this.$textElement = this.$el.find('.field-item:first');
./core/modules/edit/js/views/EditorView.js:181:      $form.find(':input[type!="hidden"][type!="submit"]:not(select)')
./core/modules/editor/js/editor.admin.js:694:        Drupal.filterConfiguration.statuses[filterID].active = $('[name="filters[' + filterID + '][status]"]').is(':checked');
./core/modules/editor/js/editor.formattedTextEditor.js:44:    this.$textElement = this.$el.find('.field-item:first');
./core/modules/filter/filter.admin.js:23:        if ($checkbox.is(':checked')) {
./core/modules/filter/filter.admin.js:42:          return $checkbox.is(':checked') ? Drupal.t('Enabled') : Drupal.t('Disabled');
./core/modules/locale/locale.admin.js:28:          $rowToMark.find('td:first-child .form-item').append(marker);
./core/modules/menu/menu.js:9:      if ($context.find('.form-item-menu-enabled input').is(':checked')) {
./core/modules/menu/menu.js:38:      if ($checkbox.is(':checked') && $link_title.val().length) {
./core/modules/menu/menu.js:47:        if ($checkbox.is(':checked')) {
./core/modules/menu/menu.js:61:        if (!$link_title.data('menuLinkAutomaticTitleOveridden') && $checkbox.is(':checked')) {
./core/modules/node/content_types.js:24:      if (!$(context).find('#edit-settings-node-options-status').is(':checked')) {
./core/modules/node/content_types.js:46:      if (!$context.find('#edit-settings-node-submitted').is(':checked')) {
./core/modules/node/node.js:21:      if (revisionCheckbox.is(':checked') || (!revisionCheckbox.length && $context.find('.form-item-log textarea').length)) {
./core/modules/node/node.js:41:      if ($context.find('input').is(':checked')) {
./core/modules/node/node.js:58:        translate = $checkbox.is(':checked') ? Drupal.t('Needs to be updated') : Drupal.t('Does not need to be updated');
./core/modules/node/node.js:62:        translate = $checkbox.is(':checked') ? Drupal.t('Flag other translations as outdated') : Drupal.t('Do not flag other translations as outdated');
./core/modules/shortcut/shortcut.admin.js:12:      $(this).closest('form').find('.form-item-set .form-type-radio:last input').prop('checked', true);
./core/modules/views_ui/js/ajax.js:56:    if ($('input#edit-displays-live-preview').is(':checked')) {
./core/modules/views_ui/js/ajax.js:91:        if ($(this).is(':checked')) {
./core/modules/views_ui/js/views-admin.js:177:  this.$form.find('.views-filterable-options :checkbox').on('click', $.proxy(this.handleCheck, this));
./core/modules/views_ui/js/views-admin.js:188:  if ($target.is(':checked')) {
./core/modules/views_ui/js/views-admin.js:264:      if ($this.children('.action-list').is(':visible')) {
./core/modules/views_ui/js/views-admin.js:409:    if ($('#edit-displays-live-preview').once('edit-displays-live-preview').is(':checked')) {
./core/modules/views_ui/js/views-admin.js:692:      var $firstCell = $draggableRow.find('td:first');
./core/modules/views_ui/js/views-admin.js:770:        var checked = $(this).is(':checked');
./core/modules/views_ui/js/views-admin.js:847:  this.$input = this.$parent.find('input:checkbox, input:radio');
tarekdj’s picture

I think I can find some time to work on it. nod_ any plan yet ?

tarekdj’s picture

LewisNyman’s picture

Issue tags: +frontend, +JavaScript
mgifford’s picture

Assigned: tarekdj » Unassigned
Wim Leers’s picture

Do we still want to do this? If so, we should decide it now. At this point, it might still be acceptable, because disruption will be low. Once 8.0.0 is out, I don't think we can do this anymore.

Lord_of_Codes’s picture

Status: Active » Closed (won't fix)
droplet’s picture

Status: Closed (won't fix) » Active

Version: 8.0.x-dev » 8.1.x-dev

Drupal 8.0.6 was released on April 6 and is the final bugfix release for the Drupal 8.0.x series. Drupal 8.0.x will not receive any further development aside from security fixes. Drupal 8.1.0-rc1 is now available and sites should prepare to update to 8.1.0.

Bug reports should be targeted against the 8.1.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.2.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

ttkoch’s picture

Issue tags: -Novice, -js-novice

Untagging this as novice because

reopened, derailed, or shifting direction, because they can be very confusing.

according to:
https://www.drupal.org/core-mentoring/novice-tasks#avoid

droplet’s picture

Priority: Normal » Minor
Status: Active » Postponed

Thanks all for your hard-working and I'm sorry I didn't help the patches move forward.

I postponed it for now, and I think we need a better way and right timing for these issues in the future.

Version: 8.1.x-dev » 8.2.x-dev

Drupal 8.1.9 was released on September 7 and is the final bugfix release for the Drupal 8.1.x series. Drupal 8.1.x will not receive any further development aside from security fixes. Drupal 8.2.0-rc1 is now available and sites should prepare to upgrade to 8.2.0.

Bug reports should be targeted against the 8.2.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.3.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.2.x-dev » 8.3.x-dev

Drupal 8.2.6 was released on February 1, 2017 and is the final full bugfix release for the Drupal 8.2.x series. Drupal 8.2.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.3.0 on April 5, 2017. (Drupal 8.3.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.3.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.4.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.3.x-dev » 8.4.x-dev

Drupal 8.3.6 was released on August 2, 2017 and is the final full bugfix release for the Drupal 8.3.x series. Drupal 8.3.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.4.0 on October 4, 2017. (Drupal 8.4.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.4.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.5.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.4.x-dev » 8.5.x-dev

Drupal 8.4.4 was released on January 3, 2018 and is the final full bugfix release for the Drupal 8.4.x series. Drupal 8.4.x will not receive any further development aside from critical and security fixes. Sites should prepare to update to 8.5.0 on March 7, 2018. (Drupal 8.5.0-alpha1 is available for testing.)

Bug reports should be targeted against the 8.5.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.6.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.5.x-dev » 8.6.x-dev

Drupal 8.5.6 was released on August 1, 2018 and is the final bugfix release for the Drupal 8.5.x series. Drupal 8.5.x will not receive any further development aside from security fixes. Sites should prepare to update to 8.6.0 on September 5, 2018. (Drupal 8.6.0-rc1 is available for testing.)

Bug reports should be targeted against the 8.6.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.7.x-dev branch. For more information see the Drupal 8 minor version schedule and the Allowed changes during the Drupal 8 release cycle.

Version: 8.6.x-dev » 8.8.x-dev

Drupal 8.6.x will not receive any further development aside from security fixes. Bug reports should be targeted against the 8.8.x-dev branch from now on, and new development or disruptive changes should be targeted against the 8.9.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.7 was released on June 3, 2020 and is the final full bugfix release for the Drupal 8.8.x series. Drupal 8.8.x will not receive any further development aside from security fixes. Sites should prepare to update to Drupal 8.9.0 or Drupal 9.0.0 for ongoing support.

Bug reports should be targeted against the 8.9.x-dev branch from now on, and new development or disruptive changes should be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

nod_’s picture

Version: 8.9.x-dev » 9.3.x-dev
Priority: Minor » Normal
Status: Postponed » Needs work
Issue tags: -JavaScript +JavaScript
Related issues: +#3239042: Refactor (if feasible) uses of the jQuery sizzle to use vanillaJS

Timing might be better this time around :)

bnjmnm’s picture

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

xjm’s picture

Priority: Normal » Major
Issue tags: +Drupal 10

Promoting to major alongside the parent.

xjm’s picture

Title: [META] Make CORE compatible with jQuery native-API selector » [META] Make core compatible with jQuery native-API selector

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.