A PR for this issue is already submitted, but here is a patch for those who need it in the meantime.
I have run into the same issue with a similar situation. Update from 9.5 -> 10.2.3. Aggregated JS files report the error notated in the original post.
Disabling JS Aggregation makes the problem go away.
Keeping JS Aggregation enabled but updating the line that @SirJohn96 outlined makes the problem go away.
I'm attaching a patch for others' use if they run into this until we can figure out why.
You are correct. I did do it that way originally, but in my copy/pasting to get it into the post, I did not change it back to context.
I understand it's the holidays, but just chiming in that I'm very interested to see @cosmicdreams's demos of this.
I've been experimenting with HTMX on a project, and it works great for giving the site a SPA-like feel. The problem I've run into is one typical of AJAX loaded content; That is, Javascript won't fire on subsequent page loads because the content was not a part of the DOM. HTMX's onLoad() function (https://htmx.org/docs/#3rd-party) is the remedy for this, and I can make it work if I write vanilla JS, but I do not know how to integrate it with Drupal behaviors.
This works. It fires on every "page" loaded via HTMX:
(function (Drupal, once, htmx, drupalSettings) {
'use strict';
htmx.onLoad(function(content) {
var items = document.querySelectorAll('.js-listItem');
console.log(items);
});
})(Drupal, once, htmx, drupalSettings);
These do not:
(function (Drupal, once, htmx, drupalSettings) {
'use strict';
Drupal.behaviors.testHTMX = {
attach: (context, settings) => {
var items = context.querySelector('.js-listItem');
console.log(items);
}
};
})(Drupal, once, htmx, drupalSettings);
(function (Drupal, once, htmx, drupalSettings) {
'use strict';
Drupal.behaviors.testHTMX = {
attach: (context, settings) => {
htmx.onLoad(function(content) {
var items = document.querySelectorAll('.js-listItem');
console.log(items);
});
}
};
})(Drupal, once, htmx, drupalSettings);
Let me know if there is any assistance I can provide in moving this forward. I'm no JS expert, but I am happy to assist where I can.
Can this be reopened until the PR is merged into a release branch, or the -dev version? Until at least the core_version_requirements are updated in the .info file, a composer install of this project in a new or upgraded D10 will not work because it checks the version before it tries to apply any sort of patch.