Issue #3268550 by longwave, Spokje: Remove deprecated jquery-once

merge-requests/1966/head
Lauri Eskola 2022-03-11 11:56:26 +02:00
parent 801e645ece
commit 7362987e37
No known key found for this signature in database
GPG Key ID: 382FC0F5B0DF53F8
36 changed files with 1 additions and 482 deletions

View File

@ -45,8 +45,6 @@ JavaScript
jQuery Metadata - Copyright (c) 2006 John Resig, Yehuda Katz, Jörn Zaefferer,
Paul McLanahan
jQuery Once - Copyright (c) 2009 Konstantin Käfer
jQuery UI - Copyright (c) 2015 by the authors and other contributors
(http://jqueryui.com/about)

View File

@ -1,177 +0,0 @@
/*!
* jQuery Once v2.2.3 - http://github.com/robloach/jquery-once
* @license MIT, GPL-2.0
* http://opensource.org/licenses/MIT
* http://opensource.org/licenses/GPL-2.0
*/
/**
* Universal Module Definition
*
* jQuery Once has a dependency on jQuery, so we wrap the code with a UMD
* pattern in order to allow loading jQuery and jQuery Once through a module
* definition like CommonJS, AMD, or through a global object.
*
* @see {@link http://github.com/umdjs/umd}
*/
(function (factory) {
'use strict';
if (typeof exports === 'object' && typeof exports.nodeName !== 'string') {
// CommonJS
factory(require('jquery'));
} else if (typeof define === 'function' && define.amd) {
// AMD
/* globals define */
define(['jquery'], factory);
} else {
// Global object
/* globals jQuery */
factory(jQuery);
}
})(function ($) {
'use strict';
/**
* Ensures that the given ID is valid, returning 'once' if one is not given.
*
* @param {string} [id=once]
* A string representing the ID to check. Defaults to `'once'`.
*
* @returns {number} The valid ID name.
*
* @throws TypeError when an ID is provided, but not a string.
* @private
*/
var checkId = function (id) {
id = id || 'once';
if (typeof id !== 'string') {
throw new TypeError('The jQuery Once id parameter must be a string');
}
return id;
};
/**
* Filter elements that have yet to be processed by the given data ID.
*
* @param {string} [id=once]
* The data ID used to determine whether the given elements have already
* been processed or not. Defaults to `'once'`.
*
* @returns {jQuery} jQuery collection of elements that have now run once by
* the given ID.
*
* @example
* ``` javascript
* // The following will change the color of each paragraph to red, just once
* // for the 'changecolor' key.
* $('p').once('changecolor').css('color', 'red');
*
* // .once() will return a set of elements that yet to have the once ID
* // associated with them. You can return to the original collection set by
* // using .end().
* $('p')
* .once('changecolorblue')
* .css('color', 'blue')
* .end()
* .css('color', 'red');
*
* // To execute a function on the once set, you can use jQuery's each().
* $('div.calendar').once().each(function () {
* // Since there is no once ID provided here, the key will be 'once'.
* });
* ```
*
* @see removeOnce
* @see findOnce
* @this jQuery
*
* @global
* @public
*/
$.fn.once = function (id) {
// Build the jQuery Once data name from the provided ID.
var name = 'jquery-once-' + checkId(id);
// Find elements that don't have the jQuery Once data applied to them yet.
return this.filter(function () {
return $(this).data(name) !== true;
}).data(name, true);
};
/**
* Removes the once data from elements, based on the given ID.
*
* @param {string} [id=once]
* A string representing the name of the data ID which should be used when
* filtering the elements. This only filters elements that have already been
* processed by the once function. The ID should be the same ID that was
* originally passed to the once() function. Defaults to `'once'`.
*
* @returns {jQuery} jQuery collection of elements that were acted upon to remove their
* once data.
*
* @example
* ``` javascript
* // Remove once data with the 'changecolor' ID. The result set is the
* // elements that had their once data removed.
* $('p').removeOnce('changecolor').css('color', '');
*
* // Any jQuery function can be performed on the result set.
* $('div.calendar').removeOnce().each(function () {
* // Remove the calendar behavior.
* });
* ```
*
* @see once
* @this jQuery
*
* @global
* @public
*/
$.fn.removeOnce = function (id) {
// Filter through the elements to find the once'd elements.
return this.findOnce(id).removeData('jquery-once-' + checkId(id));
};
/**
* Filters elements that have already been processed once.
*
* @param {string} [id=once]
* A string representing the name of the data id which should be used when
* filtering the elements. This only filters elements that have already
* been processed by the once function. The id should be the same id that
* was originally passed to the once() function. Defaults to 'once'.
*
* @returns {jQuery} jQuery collection of elements that have been run once.
*
* @example
* ``` javascript
* // Find all elements that have been changecolor'ed once.
* $('p').findOnce('changecolor').each(function () {
* // This function is called for all elements that has already once'd.
* });
*
* // Find all elements that have been acted on with the default 'once' key.
* $('p').findOnce().each(function () {
* // This function is called for all elements that have been acted on with
* // a 'once' action.
* });
* ```
*
* @see once
* @this jQuery
*
* @global
* @public
*/
$.fn.findOnce = function (id) {
// Filter the elements by which do have the data.
var name = 'jquery-once-' + checkId(id);
return this.filter(function () {
return $(this).data(name) === true;
});
};
});

View File

@ -1,8 +0,0 @@
/*!
* jQuery Once v2.2.3 - http://github.com/robloach/jquery-once
* @license MIT, GPL-2.0
* http://opensource.org/licenses/MIT
* http://opensource.org/licenses/GPL-2.0
*/
(function(e){"use strict";if(typeof exports==="object"&&typeof exports.nodeName!=="string"){e(require("jquery"))}else if(typeof define==="function"&&define.amd){define(["jquery"],e)}else{e(jQuery)}})(function(t){"use strict";var r=function(e){e=e||"once";if(typeof e!=="string"){throw new TypeError("The jQuery Once id parameter must be a string")}return e};t.fn.once=function(e){var n="jquery-once-"+r(e);return this.filter(function(){return t(this).data(n)!==true}).data(n,true)};t.fn.removeOnce=function(e){return this.findOnce(e).removeData("jquery-once-"+r(e))};t.fn.findOnce=function(e){var n="jquery-once-"+r(e);return this.filter(function(){return t(this).data(n)===true})}});
//# sourceMappingURL=jquery.once.min.js.map

View File

@ -1 +0,0 @@
{"version":3,"sources":["jquery.once.js"],"names":["factory","exports","nodeName","require","define","amd","jQuery","$","checkId","id","TypeError","fn","once","name","this","filter","data","removeOnce","findOnce","removeData"],"mappings":";;;;;;CAgBA,SAAWA,GACT,aAEA,UAAWC,UAAY,iBAAmBA,QAAQC,WAAa,SAAU,CAEvEF,EAAQG,QAAQ,gBACX,UAAWC,SAAW,YAAcA,OAAOC,IAAK,CAGrDD,OAAO,CAAC,UAAWJ,OACd,CAGLA,EAAQM,UAbZ,CAeG,SAAUC,GACX,aAaA,IAAIC,EAAU,SAAUC,GACtBA,EAAKA,GAAM,OACX,UAAWA,IAAO,SAAU,CAC1B,MAAM,IAAIC,UAAU,iDAGtB,OAAOD,GAyCTF,EAAEI,GAAGC,KAAO,SAAUH,GAEpB,IAAII,EAAO,eAAiBL,EAAQC,GAGpC,OAAOK,KAAKC,OAAO,WACjB,OAAOR,EAAEO,MAAME,KAAKH,KAAU,OAC7BG,KAAKH,EAAM,OAiChBN,EAAEI,GAAGM,WAAa,SAAUR,GAE1B,OAAOK,KAAKI,SAAST,GAAIU,WAAW,eAAiBX,EAAQC,KAkC/DF,EAAEI,GAAGO,SAAW,SAAUT,GAExB,IAAII,EAAO,eAAiBL,EAAQC,GAEpC,OAAOK,KAAKC,OAAO,WACjB,OAAOR,EAAEO,MAAME,KAAKH,KAAU","file":"jquery.once.min.js"}

View File

@ -357,7 +357,6 @@ drupal.ajax:
- core/drupal.nodelist.foreach
- core/drupal.progress
- core/once
- core/jquery.once.bc
- core/tabbable
drupal.announce:
@ -442,7 +441,6 @@ drupal.batch:
- core/drupal.ajax
- core/drupal.progress
- core/once
- core/jquery.once.bc
drupal.checkbox:
version: VERSION
@ -463,7 +461,6 @@ drupal.collapse:
- core/drupal
- core/drupal.form
- core/once
- core/jquery.once.bc
drupal.customevent:
version: VERSION
@ -574,7 +571,6 @@ drupal.dropbutton:
- core/drupal
- core/drupalSettings
- core/once
- core/jquery.once.bc
drupal.element.closest:
version: VERSION
@ -604,7 +600,6 @@ drupal.form:
- core/drupal
- core/drupal.debounce
- core/once
- core/jquery.once.bc
drupal.machine-name:
version: VERSION
@ -613,7 +608,6 @@ drupal.machine-name:
dependencies:
- core/jquery
- core/once
- core/jquery.once.bc
- core/drupal
- core/drupalSettings
- core/drupal.form
@ -654,7 +648,6 @@ drupal.states:
- core/drupal
- core/drupalSettings
- core/once
- core/jquery.once.bc
drupal.string.includes:
version: VERSION
@ -679,7 +672,6 @@ drupal.tabledrag:
- core/drupal
- core/drupalSettings
- core/once
- core/jquery.once.bc
drupal.tableheader:
version: VERSION
@ -690,7 +682,6 @@ drupal.tableheader:
- core/drupal
- core/drupalSettings
- core/once
- core/jquery.once.bc
- core/drupal.displace
drupal.tableresponsive:
@ -701,7 +692,6 @@ drupal.tableresponsive:
- core/jquery
- core/drupal
- core/once
- core/jquery.once.bc
drupal.tableselect:
version: VERSION
@ -712,7 +702,6 @@ drupal.tableselect:
- core/drupal.checkbox
- core/jquery
- core/once
- core/jquery.once.bc
drupal.timezone:
version: VERSION
@ -722,7 +711,6 @@ drupal.timezone:
- core/drupal.nodelist.foreach
- core/jquery
- core/once
- core/jquery.once.bc
- core/drupal
drupal.vertical-tabs:
@ -736,7 +724,6 @@ drupal.vertical-tabs:
dependencies:
- core/jquery
- core/once
- core/jquery.once.bc
- core/drupal
- core/drupalSettings
- core/drupal.form
@ -808,33 +795,6 @@ shepherd:
js:
assets/vendor/shepherd/shepherd.min.js: { minified: true }
jquery.once:
remote: https://github.com/RobLoach/jquery-once
version: "2.2.3"
license:
name: GNU-GPL-2.0-or-later
url: https://raw.githubusercontent.com/RobLoach/jquery-once/2.2.3/LICENSE.md
gpl-compatible: true
js:
assets/vendor/jquery-once/jquery.once.min.js: { weight: -19, minified: true }
dependencies:
- core/jquery
- 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:
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
jquery.ui:
version: &jquery_ui_version "1.13.1"
license: &jquery_ui_license
@ -1144,7 +1104,6 @@ drupal.dialog.off_canvas:
dependencies:
- core/jquery
- core/once
- core/jquery.once.bc
- core/drupal
- core/drupal.ajax
- core/drupal.announce

View File

@ -1,55 +0,0 @@
/**
* @file
* This file allows calls to `once()` and `once.remove()` to also populate the
* jQuery.once registry.
*
* It allows contributed code still using jQuery.once to behave as expected:
* @example
* once('core-once-call', 'body');
*
* // The following will work in a contrib module still using jQuery.once:
* $('body').once('core-once-call'); // => returns empty object
*/
(($, 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) {
// 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) {
// Do not trigger deprecation warnings for the BC layer calls.
originalJQRemoveOnce.apply($(selector, context), [id]);
return drupalOnce.remove(id, selector, context);
}
// Expose the rest of @drupal/once API and replace @drupal/once library with
// the version augmented with jQuery.once calls.
window.once = Object.assign(augmentedOnce, drupalOnce, { remove });
})(jQuery, once);

View File

@ -1,42 +0,0 @@
/**
* DO NOT EDIT THIS FILE.
* See the following change record for more information,
* https://www.drupal.org/node/2815083
* @preserve
**/
(($, 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`;
const originalJQOnce = $.fn.once;
const originalJQRemoveOnce = $.fn.removeOnce;
$.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]);
};
const drupalOnce = once;
function augmentedOnce(id, selector, context) {
originalJQOnce.apply($(selector, context), [id]);
return drupalOnce(id, selector, context);
}
function remove(id, selector, context) {
originalJQRemoveOnce.apply($(selector, context), [id]);
return drupalOnce.remove(id, selector, context);
}
window.once = Object.assign(augmentedOnce, drupalOnce, {
remove
});
})(jQuery, once);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -10,7 +10,6 @@ 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

@ -34,7 +34,6 @@ ui:
- core/drupal.announce
- core/drupal.nodelist.foreach
- core/once
- core/jquery.once.bc
- core/jquery
- media_library/view
- core/tabbable

View File

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

View File

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

View File

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

View File

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

View File

@ -5,10 +5,3 @@ js_once_test:
_title: 'OnceTest'
requirements:
_access: 'TRUE'
js_once_test.with_bc:
path: '/js_once_with_bc_test'
defaults:
_controller: '\Drupal\js_once_test\Controller\JsOnceTestController::onceBcTest'
_title: 'OnceBcTest'
requirements:
_access: 'TRUE'

View File

@ -32,27 +32,4 @@ class JsOnceTestController extends ControllerBase {
return $output;
}
/**
* Provides elements for testing jQuery Once BC support.
*
* @return array
* The render array.
*/
public function onceBcTest() {
$output = [
'#attached' => ['library' => ['core/jquery.once']],
];
foreach (range(1, 5) as $item) {
$output['item' . $item] = [
'#type' => 'html_tag',
'#tag' => 'div',
'#value' => 'Item ' . $item,
'#attributes' => [
'data-drupal-item' => $item,
],
];
}
return $output;
}
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -9,7 +9,6 @@ views_ui.admin:
- core/drupal
- core/drupalSettings
- core/once
- core/jquery.once.bc
- core/jquery.form
- core/drupal.form
- core/drupal.ajax
@ -27,7 +26,6 @@ views_ui.listing:
- core/drupal
- core/drupal.string.includes
- core/once
- core/jquery.once.bc
- views_ui/admin.styling
admin.styling:

View File

@ -83,7 +83,6 @@
"glob": "^7.1.2",
"jquery": "^3.6.0",
"jquery-form": "^4.3.0",
"jquery-once": "^2.2.3",
"jquery-ui": "~1.13.1",
"js-cookie": "^3.0.1",
"jsdom": "^18.0.1",

View File

@ -122,11 +122,6 @@ const assetsFolder = `${coreFolder}/assets/vendor`;
{ from: 'src/jquery.form.js', to: 'src/jquery.form.js' },
],
},
{
pack: 'jquery-once',
library: 'jquery.once',
files: ['jquery.once.js', 'jquery.once.min.js', 'jquery.once.min.js.map'],
},
{
pack: 'js-cookie',
files: [{ from: 'dist/js.cookie.min.js', to: 'js.cookie.min.js' }],

View File

@ -132,79 +132,4 @@ module.exports = {
)
.drupalLogAndEnd({ onlyOnError: false });
},
'Test BC layer with jQuery Once calls': (browser) => {
browser
.drupalRelativeURL('/js_once_with_bc_test')
.waitForElementVisible('[data-drupal-item]', 1000)
// prettier-ignore
.execute(
function () {
// A core script calls once on some elements.
once('js_once_test', '[data-drupal-item]');
// A contrib module not yet using @drupal/once calls jQuery Once.
return jQuery('[data-drupal-item]').once('js_once_test');
},
(result) => {
browser.assert.strictEqual(
result.value.length,
0,
'Calls to once() are taken into account when using jQuery.once()',
);
},
)
// Once calls don't take into account calls to jQuery.once by design.
.execute(
function () {
// Calling jQuery.once before @drupal/once will lead to duplicate
// processing.
jQuery('[data-drupal-item]').once('js_once_test_extra');
// A core script calls once on some elements.
return once('js_once_test_extra', '[data-drupal-item]');
},
(result) => {
browser.assert.strictEqual(
result.value.length,
5,
'5 items returned by once() after a call to jQuery.once()',
);
},
)
.execute(
function () {
once('js_once_test_remove', '[data-drupal-item]');
// A core script calls once on some elements.
once.remove('js_once_test_remove', '[data-drupal-item]');
// A contrib module not yet using @drupal/once calls the jQuery Once
// remove() function.
return jQuery('[data-drupal-item]').removeOnce('js_once_test_remove');
},
(result) => {
browser.assert.strictEqual(
result.value.length,
0,
'Calls to once.remove() are taken into account when using jQuery.removeOnce()',
);
},
)
// Once.remove calls don't take into account calls to jQuery.removeOnce by
// design.
.execute(
function () {
once('js_once_test_remove_fail', '[data-drupal-item]');
// Calling jQuery.removeOnce before @drupal/once will lead to
// duplicate processing.
jQuery('[data-drupal-item]').removeOnce('js_once_test_remove_fail');
// A core script calls once.remove on some elements.
return once.remove('js_once_test_remove_fail', '[data-drupal-item]');
},
(result) => {
browser.assert.strictEqual(
result.value.length,
5,
'5 items returned by once.remove() after a call to jQuery.removeOnce()',
);
},
)
.drupalLogAndEnd({ onlyOnError: false });
},
};

View File

@ -5034,13 +5034,6 @@ jquery-form@^4.3.0:
dependencies:
jquery ">=1.7.2"
jquery-once@^2.2.3:
version "2.2.3"
resolved "https://registry.yarnpkg.com/jquery-once/-/jquery-once-2.2.3.tgz#d5b266a1a7b47e5f86a5f25e83ee9467e13707a3"
integrity sha512-5gbkmxjbqA15KbrNxcDhdBN3EvakY5w/JdxdGgPGsO/kp6TdiqOr6nbnEZGeyF1/yLXVvA8i9lisgXguSiNV+g==
dependencies:
jquery "*"
jquery-ui@~1.13.1:
version "1.13.1"
resolved "https://registry.yarnpkg.com/jquery-ui/-/jquery-ui-1.13.1.tgz#d0b7a42e73a04c31bb5706adf86f6f8942f64eaa"
@ -5048,7 +5041,7 @@ jquery-ui@~1.13.1:
dependencies:
jquery ">=1.8.0 <4.0.0"
jquery@*, jquery@>=1.7.2, "jquery@>=1.8.0 <4.0.0", jquery@^3.6.0:
jquery@>=1.7.2, "jquery@>=1.8.0 <4.0.0", jquery@^3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.6.0.tgz#c72a09f15c1bdce142f49dbf1170bdf8adac2470"
integrity sha512-JVzAR/AjBvVt2BmYhxRCSYysDsPcssdmTFnzyLEts9qNwmjmu4JTAMYubEfwVOSwpQ1I1sKKFcxhZCI2buerfw==