var content = this.textContent.trim();
if (typeof drupalSettings.bigPipePlaceholderIds[placeholderId] !== 'undefined') {
- if (content === '') {
+ var response = mapTextContentToAjaxResponse(content);
+
+ if (response === false) {
$(this).removeOnce('big-pipe');
} else {
- var response = JSON.parse(content);
-
var ajaxObject = Drupal.ajax({
url: '',
base: false,
}
}
+ function mapTextContentToAjaxResponse(content) {
+ if (content === '') {
+ return false;
+ }
+
+ try {
+ return JSON.parse(content);
+ } catch (e) {
+ return false;
+ }
+ }
+
function bigPipeProcessDocument(context) {
if (!context.querySelector('script[data-big-pipe-event="start"]')) {
return false;