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

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"]

kool.

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

Assigned:Unassigned» littledynamo

Assigned:littledynamo» Unassigned

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?

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.

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

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. :)

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');

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