Commit 4d44229b authored by Julian Pustkuchen's avatar Julian Pustkuchen
Browse files

Issue #3274995: Facebook pixel submodule's JS is never attached

parent 22e82ed6
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -61,7 +61,8 @@ function cookies_facebook_pixel_page_attachments(&$page) {
function cookies_facebook_pixel_js_alter(array &$javascript, AttachedAssetsInterface $assets) {
  $doKo = CookiesKnockOutService::getInstance()->doKnockOut();
  if ($doKo) {
    $script = 'modules/contrib/facebook_pixel/js/facebook_pixel.js';
    $modulePath = \Drupal::service('module_handler')->getModule('facebook_pixel')->getPath();
    $script = $modulePath . '/js/facebook_pixel.js';
    if (isset($javascript[$script])) {
      $javascript[$script]['preprocess'] = false;
      $javascript[$script]['attributes']['type'] = 'application/json';
+6 −0
Original line number Diff line number Diff line
@@ -29,6 +29,12 @@
          }
          newScript.innerHTML = content;
          script.parentNode.replaceChild(newScript, script);

          // We have to call the attach() from facebook_pixel manually,
          // otherwise the script won't be initialized.
          if (Drupal.behaviors.facebook_pixel.attach && typeof Drupal.behaviors.facebook_pixel.attach === 'function') {
            Drupal.behaviors.facebook_pixel.attach(document);
          }
        }
      }
    },