FIX: browser infinite recursion when editing post

FIX: browser infinite recursion when editing post

This was a result of:

jQuery map on a jQuery object, returns a jQuery object .map() | jQuery API Documentation

So you need to convert it to an array prior to mapping

From 0a86ef69bb5c7ae425aac4d645da370f150987a3 Mon Sep 17 00:00:00 2001
From: Sam <sam.saffron@gmail.com>
Date: Wed, 21 Nov 2018 12:51:14 +1100
Subject: [PATCH] FIX: browser infinite recursion when editing post

This was a result of:

https://github.com/discourse/discourse/commit/c4ed353fae4280541f8f4c52d9ab43486bd11ba2

jQuery map on a jQuery object, returns a jQuery object http://api.jquery.com/map/

So you need to convert it to an array prior to mapping

diff --git a/app/assets/javascripts/pretty-text/image-short-url.js.es6 b/app/assets/javascripts/pretty-text/image-short-url.js.es6
index 60403ba..d2e573b 100644
--- a/app/assets/javascripts/pretty-text/image-short-url.js.es6
+++ b/app/assets/javascripts/pretty-text/image-short-url.js.es6
@@ -33,7 +33,7 @@ function _loadCachedShortUrls($images) {
 }
 
 function _loadShortUrls($images, ajax) {
-  const urls = $images.map(img => $(img).data("orig-src"));
+  const urls = $images.toArray().map(img => $(img).data("orig-src"));
   lookupUncachedUploadUrls(urls, ajax).then(() =>
     _loadCachedShortUrls($images)
   );

GitHub

3 Likes