A platform for community discussion. Free, open, simple.
FIX: allow native lazy loading attribute for quoted avatar image (#15834)
Ayke Halder81e175e6ba90
diff --git a/app/assets/javascripts/pretty-text/engines/discourse-markdown/quotes.js b/app/assets/javascripts/pretty-text/engines/discourse-markdown/quotes.jsindex f43fceec0da..8eaf6dd4060 100644--- a/app/assets/javascripts/pretty-text/engines/discourse-markdown/quotes.js+++ b/app/assets/javascripts/pretty-text/engines/discourse-markdown/quotes.js@@ -170,7 +170,7 @@ export function setup(helper) {md.block.bbcode.ruler.push("quotes", rule);});- helper.allowList(["img[class=avatar]"]);+ helper.allowList(["img[class=avatar]", "img[loading=lazy]"]);helper.allowList({custom(tag, name, value) {if (tag === "aside" && name === "class") {diff --git a/spec/components/pretty_text_spec.rb b/spec/components/pretty_text_spec.rbindex 8e180c5eb51..73827007340 100644--- a/spec/components/pretty_text_spec.rb+++ b/spec/components/pretty_text_spec.rb@@ -226,7 +226,7 @@ describe PrettyText do<aside class="quote no-group" data-username="#{user.username}" data-post="123" data-topic="456" data-full="true"><div class="title"><div class="quote-controls"></div>- <img alt="" width="20" height="20" src="//test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png" class="avatar"> #{user.username}:</div>+ <img loading="lazy" alt="" width="20" height="20" src="//test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png" class="avatar"> #{user.username}:</div><blockquote><p>ddd</p></blockquote>@@ -248,7 +248,7 @@ describe PrettyText do<aside class="quote no-group" data-username="#{user.username}" data-post="123" data-topic="456" data-full="true"><div class="title"><div class="quote-controls"></div>- <img alt="" width="20" height="20" src="//test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png" class="avatar"> #{user.username}:</div>+ <img loading="lazy" alt="" width="20" height="20" src="//test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png" class="avatar"> #{user.username}:</div><blockquote><p>ddd</p></blockquote>@@ -269,7 +269,7 @@ describe PrettyText do<aside class="quote no-group" data-username="#{user.username}" data-post="555" data-topic="666"><div class="title"><div class="quote-controls"></div>- <img alt="" width="20" height="20" src="//test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png" class="avatar"> #{user.username}:</div>+ <img loading="lazy" alt="" width="20" height="20" src="//test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png" class="avatar"> #{user.username}:</div><blockquote><p>ddd</p></blockquote>@@ -296,7 +296,7 @@ describe PrettyText do<aside class="quote group-#{group.name}" data-username="#{user.username}" data-post="2" data-topic="#{topic.id}"><div class="title"><div class="quote-controls"></div>- <img alt="" width="20" height="20" src="//test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png" class="avatar"><a href="http://test.localhost/t/this-is-a-test-topic/#{topic.id}/2">This is a test topic</a>+ <img loading="lazy" alt="" width="20" height="20" src="//test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png" class="avatar"><a href="http://test.localhost/t/this-is-a-test-topic/#{topic.id}/2">This is a test topic</a></div><blockquote><p>ddd</p>