Problem/Motivation
Currently, Drupal.AjaxCommands.prototype.insert() always wraps the returned HTML in a div. There are multiple conditions where even the more limited DIV wrapping creates problems (see comments #41-#48).
Proposed resolution
Do not wrap the returned content at all. No confusing logic on what gets wrapped and what does not. See #246 - #257 for some additional context on this decision.
// Parse response.data into an element collection.
const $newContent = $($.parseHTML(response.data, true));
// ...
// Add the new content to the page.
$wrapper[method]($newContent);
See #296 for the latest patch.
Remaining tasks
🎉™️