Skip to content

Commit

Permalink
No need to use once()
Browse files Browse the repository at this point in the history
  • Loading branch information
andmor- committed Dec 15, 2023
1 parent 00b7bbb commit 04da9da
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
3 changes: 1 addition & 2 deletions clarin_bootstrap.libraries.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,4 @@ clarin_toc:
component:
css/bootstrap-toc.min.css: { }
dependencies:
- core/drupal
- core/once
- core/drupal
12 changes: 6 additions & 6 deletions js/toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,23 @@
* Initialize TOC
*
*/
(($, Drupal, once) => {
(($, Drupal) => {
Drupal.behaviors.clarin_theme_toc = {
attach: function attach(context) {
if (context === document) {
if (context === document && document.readyState !== "loading") {
$(function initToc() {
const navSelector = "#toc";
const scopeSelector = "#tocscope";
Toc.init({
$nav: $(once("selectorID", navSelector, context)),
$scope: $(once("selectorID", scopeSelector, context))
$nav: $(navSelector, context),
$scope: $(scopeSelector, context)
});
const body = $(once("selectorID", "body", context));
const body = $("body", context);
body.scrollspy({
target: navSelector
});
});
}
}
};
})(jQuery, Drupal, once);
})(jQuery, Drupal);

0 comments on commit 04da9da

Please sign in to comment.