Issue #3244855 by nod_, alexpott, catch: Regression in Drupal 9.3.x due to jQuery.once deprecation

merge-requests/1185/merge
catch 2021-10-29 11:32:32 +01:00
parent e35c56bcb3
commit b7e8bd496e
26 changed files with 100 additions and 5 deletions

View File

@ -85,6 +85,7 @@ drupal.ajax:
- core/drupalSettings
- core/drupal.progress
- core/once
- core/jquery.once.bc
- core/tabbable
drupal.announce:
@ -165,6 +166,7 @@ drupal.batch:
- core/drupal.ajax
- core/drupal.progress
- core/once
- core/jquery.once.bc
drupal.checkbox:
version: VERSION
@ -185,6 +187,7 @@ drupal.collapse:
- core/drupal
- core/drupal.form
- core/once
- core/jquery.once.bc
drupal.customevent:
version: VERSION
@ -296,6 +299,7 @@ drupal.dropbutton:
- core/drupal
- core/drupalSettings
- core/once
- core/jquery.once.bc
drupal.element.closest:
version: VERSION
@ -325,6 +329,7 @@ drupal.form:
- core/drupal
- core/drupal.debounce
- core/once
- core/jquery.once.bc
drupal.machine-name:
version: VERSION
@ -333,6 +338,7 @@ drupal.machine-name:
dependencies:
- core/jquery
- core/once
- core/jquery.once.bc
- core/drupal
- core/drupalSettings
- core/drupal.form
@ -373,6 +379,7 @@ drupal.states:
- core/drupal
- core/drupalSettings
- core/once
- core/jquery.once.bc
drupal.tabbingmanager:
version: VERSION
@ -392,6 +399,7 @@ drupal.tabledrag:
- core/drupal
- core/drupalSettings
- core/once
- core/jquery.once.bc
drupal.tableheader:
version: VERSION
@ -402,6 +410,7 @@ drupal.tableheader:
- core/drupal
- core/drupalSettings
- core/once
- core/jquery.once.bc
- core/drupal.displace
drupal.tableresponsive:
@ -412,6 +421,7 @@ drupal.tableresponsive:
- core/jquery
- core/drupal
- core/once
- core/jquery.once.bc
drupal.tableselect:
version: VERSION
@ -422,6 +432,7 @@ drupal.tableselect:
- core/drupal.checkbox
- core/jquery
- core/once
- core/jquery.once.bc
drupal.timezone:
version: VERSION
@ -430,6 +441,7 @@ drupal.timezone:
dependencies:
- core/jquery
- core/once
- core/jquery.once.bc
- core/drupal
drupal.vertical-tabs:
@ -443,6 +455,7 @@ drupal.vertical-tabs:
dependencies:
- core/jquery
- core/once
- core/jquery.once.bc
- core/drupal
- core/drupalSettings
- core/drupal.form
@ -546,11 +559,15 @@ jquery.once:
- 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
# Internal library, do not depend on it.
# The library will be removed in Drupal 10.0.0.
jquery.once.bc:
version: VERSION
js:
misc/jquery.once.bc.js: { weight: -19 }
assets/vendor/jquery-once/jquery.once.min.js: { weight: -19, minified: true }
misc/jquery.once.bc.js: {}
dependencies:
- core/drupal
- core/jquery
- core/once
- core/drupal.object.assign
@ -866,6 +883,7 @@ drupal.dialog.off_canvas:
dependencies:
- core/jquery
- core/once
- core/jquery.once.bc
- core/drupal
- core/drupal.ajax
- core/drupal.announce

View File

@ -12,18 +12,40 @@
*/
(($, once) => {
const deprecatedMessageSuffix = `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`;
// Trigger a deprecation error when using jQuery.once methods.
const originalJQOnce = $.fn.once;
const originalJQRemoveOnce = $.fn.removeOnce;
// Do not deprecate findOnce because it is used internally by jQuery.once().
$.fn.once = function jQueryOnce(id) {
Drupal.deprecationError({
message: `jQuery.once() ${deprecatedMessageSuffix}`,
});
return originalJQOnce.apply(this, [id]);
};
$.fn.removeOnce = function jQueryRemoveOnce(id) {
Drupal.deprecationError({
message: `jQuery.removeOnce() ${deprecatedMessageSuffix}`,
});
return originalJQRemoveOnce.apply(this, [id]);
};
// We'll replace the whole library so keep a version in cache for later.
const drupalOnce = once;
// When calling once(), also populate jQuery.once registry.
function augmentedOnce(id, selector, context) {
$(selector, context).once(id);
// Do not trigger deprecation warnings for the BC layer calls.
originalJQOnce.apply($(selector, context), [id]);
return drupalOnce(id, selector, context);
}
// When calling once.remove(), also remove it from jQuery.once registry.
function remove(id, selector, context) {
$(selector, context).removeOnce(id);
// Do not trigger deprecation warnings for the BC layer calls.
originalJQRemoveOnce.apply($(selector, context), [id]);
return drupalOnce.remove(id, selector, context);
}

View File

@ -6,15 +6,33 @@
**/
(function ($, once) {
var deprecatedMessageSuffix = "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";
var originalJQOnce = $.fn.once;
var originalJQRemoveOnce = $.fn.removeOnce;
$.fn.once = function jQueryOnce(id) {
Drupal.deprecationError({
message: "jQuery.once() ".concat(deprecatedMessageSuffix)
});
return originalJQOnce.apply(this, [id]);
};
$.fn.removeOnce = function jQueryRemoveOnce(id) {
Drupal.deprecationError({
message: "jQuery.removeOnce() ".concat(deprecatedMessageSuffix)
});
return originalJQRemoveOnce.apply(this, [id]);
};
var drupalOnce = once;
function augmentedOnce(id, selector, context) {
$(selector, context).once(id);
originalJQOnce.apply($(selector, context), [id]);
return drupalOnce(id, selector, context);
}
function remove(id, selector, context) {
$(selector, context).removeOnce(id);
originalJQRemoveOnce.apply($(selector, context), [id]);
return drupalOnce.remove(id, selector, context);
}

View File

@ -6,6 +6,7 @@ drupal.block:
- core/jquery
- core/drupal
- core/once
- core/jquery.once.bc
drupal.block.admin:
version: VERSION
@ -21,3 +22,4 @@ drupal.block.admin:
- core/drupal.debounce
- core/drupal.dialog.ajax
- core/once
- core/jquery.once.bc

View File

@ -50,6 +50,7 @@ drupal.ckeditor.admin:
- core/drupal
- core/drupalSettings
- core/once
- core/jquery.once.bc
- core/backbone
- core/drupal.dialog
- core/drupal.announce
@ -67,6 +68,7 @@ drupal.ckeditor.drupalimage.admin:
- core/jquery
- core/drupal
- core/once
- core/jquery.once.bc
- core/drupal.vertical-tabs
- core/drupalSettings

View File

@ -6,6 +6,7 @@ drupal.color:
- core/jquery
- core/drupal
- core/once
- core/jquery.once.bc
- core/jquery.farbtastic
- color/drupal.color.preview
@ -18,6 +19,7 @@ drupal.color.preview:
- core/drupal
- core/drupalSettings
- core/once
- core/jquery.once.bc
admin:
version: VERSION

View File

@ -23,6 +23,7 @@ drupal.comment-new-indicator:
dependencies:
- core/jquery
- core/once
- core/jquery.once.bc
- core/drupal
- history/api
- core/drupal.displace
@ -34,5 +35,6 @@ drupal.node-new-comments-link:
dependencies:
- core/jquery
- core/once
- core/jquery.once.bc
- core/drupal
- history/api

View File

@ -9,3 +9,4 @@ drupal.content_translation.admin:
- core/jquery
- core/drupal
- core/once
- core/jquery.once.bc

View File

@ -25,6 +25,7 @@ drupal.contextual-links:
- core/backbone
- core/modernizr
- core/once
- core/jquery.once.bc
drupal.contextual-toolbar:
version: VERSION
@ -43,5 +44,6 @@ drupal.contextual-toolbar:
- core/drupal
- core/backbone
- core/once
- core/jquery.once.bc
- core/drupal.tabbingmanager
- core/drupal.announce

View File

@ -5,6 +5,7 @@ drupal.editor.admin:
dependencies:
- core/jquery
- core/once
- core/jquery.once.bc
- core/drupal
drupal.editor:
@ -16,6 +17,7 @@ drupal.editor:
- core/drupal
- core/drupalSettings
- core/once
- core/jquery.once.bc
- core/drupal.dialog
drupal.editor.dialog:

View File

@ -10,3 +10,4 @@ drupal.field_ui:
- core/drupal
- core/drupalSettings
- core/once
- core/jquery.once.bc

View File

@ -5,5 +5,6 @@ drupal.file:
dependencies:
- core/jquery
- core/once
- core/jquery.once.bc
- core/drupal
- core/drupalSettings

View File

@ -6,6 +6,7 @@ drupal.filter.admin:
- core/jquery
- core/drupal
- core/once
- core/jquery.once.bc
- core/drupal.form
drupal.filter.filter_html.admin:
@ -15,6 +16,7 @@ drupal.filter.filter_html.admin:
dependencies:
- core/jquery
- core/once
- core/jquery.once.bc
- core/underscore
drupal.filter:
@ -25,6 +27,7 @@ drupal.filter:
- core/jquery
- core/drupal
- core/once
- core/jquery.once.bc
caption:
version: VERSION

View File

@ -9,3 +9,4 @@ drupal.language.admin:
- core/jquery
- core/drupal
- core/once
- core/jquery.once.bc

View File

@ -10,6 +10,7 @@ drupal.locale.admin:
- core/drupal
- core/drupal.form
- core/once
- core/jquery.once.bc
translations:
# No sensible version can be specified, since the translations may change at

View File

@ -33,6 +33,7 @@ ui:
- core/drupal.ajax
- core/drupal.announce
- core/once
- core/jquery.once.bc
- core/jquery
- media_library/view
- core/tabbable

View File

@ -19,6 +19,7 @@ drupal.node.preview:
dependencies:
- core/jquery
- core/once
- core/jquery.once.bc
- core/drupal
- core/drupal.dialog
- core/drupal.form

View File

@ -29,6 +29,7 @@ quickedit:
dependencies:
- core/jquery
- core/once
- core/jquery.once.bc
- core/underscore
- core/backbone
- core/jquery.form

View File

@ -16,4 +16,5 @@ drupal.settings_tray:
- core/jquery
- core/drupal
- core/once
- core/jquery.once.bc
- core/drupal.ajax

View File

@ -52,6 +52,7 @@ drupal.system:
- core/drupal
- core/drupalSettings
- core/once
- core/jquery.once.bc
drupal.system.modules:
version: VERSION
@ -62,6 +63,7 @@ drupal.system.modules:
- core/drupal
- core/drupal.debounce
- core/once
- core/jquery.once.bc
- core/drupal.announce
diff:
@ -79,4 +81,5 @@ drupal.system.date:
- core/drupal
- core/drupalSettings
- core/once
- core/jquery.once.bc
- core/drupal.form

View File

@ -5,4 +5,5 @@ drupal.text:
dependencies:
- core/jquery
- core/once
- core/jquery.once.bc
- core/drupal

View File

@ -26,6 +26,7 @@ toolbar:
- core/drupal.announce
- core/backbone
- core/once
- core/jquery.once.bc
- core/drupal.displace
- toolbar/toolbar.menu
@ -40,6 +41,7 @@ toolbar.menu:
- core/jquery
- core/drupal
- core/once
- core/jquery.once.bc
toolbar.escapeAdmin:
version: VERSION
@ -50,3 +52,4 @@ toolbar.escapeAdmin:
- core/drupal
- core/drupalSettings
- core/once
- core/jquery.once.bc

View File

@ -5,6 +5,7 @@ tour:
dependencies:
- core/jquery
- core/once
- core/jquery.once.bc
- core/drupal
- core/backbone
- core/shepherd

View File

@ -10,6 +10,7 @@ drupal.user:
- core/jquery
- core/drupal
- core/once
- core/jquery.once.bc
drupal.user.admin:
version: VERSION
@ -24,6 +25,7 @@ drupal.user.permissions:
dependencies:
- core/jquery
- core/once
- core/jquery.once.bc
- core/drupal
- core/drupalSettings
- user/drupal.user.admin

View File

@ -14,5 +14,6 @@ views.ajax:
- core/drupal
- core/drupalSettings
- core/once
- core/jquery.once.bc
- core/jquery.form
- core/drupal.ajax

View File

@ -9,6 +9,7 @@ views_ui.admin:
- core/drupal
- core/drupalSettings
- core/once
- core/jquery.once.bc
- core/jquery.form
- core/drupal.form
- core/drupal.ajax
@ -24,6 +25,7 @@ views_ui.listing:
- core/jquery
- core/drupal
- core/once
- core/jquery.once.bc
- views_ui/admin.styling
admin.styling: