Problem/Motivation
BU will occasionally show up multiple times, especially in a sites front end. Here's a video: https://www.drupal.org/files/issues/2021-03-13/bu-dupe.mp4
Steps to reproduce
Install module, add #test-bu to url. Settings probably don't matter; I've included a .yml export anyway.
Proposed resolution
If bu has already been attached to the page, skip further calls during Drupal.behaviors.bu::attach()
Attached is a patch for bu.js and my patched version of bu.js
Patch wraps normal execution with:
if(typeof settings.bu.hooked === 'undefined'){
// window.$buoop = { ... document.body.appendChild(e);
settings.bu.hooked = true;
}
Remaining tasks
N/A?
User interface changes
none
API changes
drupalSettings.bu adds flag; drupalSettings.bu.hooked
Data model changes
none
Comments
Comment #2
perfectcu.be commentedComment #3
perfectcu.be commentedComment #4
perfectcu.be commentedComment #5
mingsongThe reason is that
More explanation about Drupal JS behaviors see https://www.drupal.org/docs/7/api/javascript-api/managing-javascript#beh...
The solution is as simple as putting those codes into
Comment #7
mingsongThe patch for testing.
https://git.drupalcode.org/issue/bu-3203410/-/commit/09ccad3d6cda816930e...
Comment #8
mingsongComment #9
pmkanse commentedPatch for v 2.1.1