Loading core/core.libraries.yml +10 −0 Original line number Diff line number Diff line Loading @@ -528,6 +528,16 @@ jquery.once: assets/vendor/jquery-once/jquery.once.min.js: { weight: -19, minified: true } dependencies: - core/jquery - core/jquery.once.bc jquery.once.bc: version: VERSION js: misc/jquery.once.bc.js: { weight: -19 } dependencies: - core/jquery - core/once - core/drupal.object.assign jquery.ui: version: &jquery_ui_version 1.12.1 Loading core/misc/jquery.once.bc.es6.js 0 → 100644 +33 −0 Original line number Diff line number Diff line /** * @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) => { // 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); 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); 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); core/misc/jquery.once.bc.js 0 → 100644 +24 −0 Original line number Diff line number Diff line /** * DO NOT EDIT THIS FILE. * See the following change record for more information, * https://www.drupal.org/node/2815083 * @preserve **/ (function ($, once) { var drupalOnce = once; function augmentedOnce(id, selector, context) { $(selector, context).once(id); return drupalOnce(id, selector, context); } function remove(id, selector, context) { $(selector, context).removeOnce(id); return drupalOnce.remove(id, selector, context); } window.once = Object.assign(augmentedOnce, drupalOnce, { remove: remove }); })(jQuery, once); No newline at end of file core/modules/system/tests/modules/js_once_test/js_once_test.info.yml 0 → 100644 +5 −0 Original line number Diff line number Diff line name: 'JS once Test' type: module description: 'Module for the jsOnceTest.' package: Testing version: VERSION core/modules/system/tests/modules/js_once_test/js_once_test.routing.yml 0 → 100644 +14 −0 Original line number Diff line number Diff line js_once_test: path: '/js_once_test' defaults: _controller: '\Drupal\js_once_test\Controller\JsOnceTestController::onceTest' _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' Loading
core/core.libraries.yml +10 −0 Original line number Diff line number Diff line Loading @@ -528,6 +528,16 @@ jquery.once: assets/vendor/jquery-once/jquery.once.min.js: { weight: -19, minified: true } dependencies: - core/jquery - core/jquery.once.bc jquery.once.bc: version: VERSION js: misc/jquery.once.bc.js: { weight: -19 } dependencies: - core/jquery - core/once - core/drupal.object.assign jquery.ui: version: &jquery_ui_version 1.12.1 Loading
core/misc/jquery.once.bc.es6.js 0 → 100644 +33 −0 Original line number Diff line number Diff line /** * @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) => { // 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); 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); 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);
core/misc/jquery.once.bc.js 0 → 100644 +24 −0 Original line number Diff line number Diff line /** * DO NOT EDIT THIS FILE. * See the following change record for more information, * https://www.drupal.org/node/2815083 * @preserve **/ (function ($, once) { var drupalOnce = once; function augmentedOnce(id, selector, context) { $(selector, context).once(id); return drupalOnce(id, selector, context); } function remove(id, selector, context) { $(selector, context).removeOnce(id); return drupalOnce.remove(id, selector, context); } window.once = Object.assign(augmentedOnce, drupalOnce, { remove: remove }); })(jQuery, once); No newline at end of file
core/modules/system/tests/modules/js_once_test/js_once_test.info.yml 0 → 100644 +5 −0 Original line number Diff line number Diff line name: 'JS once Test' type: module description: 'Module for the jsOnceTest.' package: Testing version: VERSION
core/modules/system/tests/modules/js_once_test/js_once_test.routing.yml 0 → 100644 +14 −0 Original line number Diff line number Diff line js_once_test: path: '/js_once_test' defaults: _controller: '\Drupal\js_once_test\Controller\JsOnceTestController::onceTest' _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'