Updated to Drupal 8.5. Core Media not yet in use.
[yaffs-website] / web / core / modules / big_pipe / js / big_pipe.js
index 1464fdd968202268b4a23be8e1004e4d1152fc3f..b8a25f77cc8987832ec660ba87dea22329419b83 100644 (file)
     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;