Merge pull request #3373 from savef/fix-user-card-avatar-alt

Add blank alt attribute to user card avatars.
This commit is contained in:
Régis Hanol 2015-04-14 16:10:35 +02:00
commit a57bbd5000
3 changed files with 7 additions and 7 deletions

View File

@ -51,7 +51,7 @@ Discourse.Utilities = {
var classes = "avatar" + (options.extraClasses ? " " + options.extraClasses : ""); var classes = "avatar" + (options.extraClasses ? " " + options.extraClasses : "");
var title = (options.title) ? " title='" + Handlebars.Utils.escapeExpression(options.title || "") + "'" : ""; var title = (options.title) ? " title='" + Handlebars.Utils.escapeExpression(options.title || "") + "'" : "";
return "<img width='" + size + "' height='" + size + "' src='" + url + "' class='" + classes + "'" + title + ">"; return "<img alt='' width='" + size + "' height='" + size + "' src='" + url + "' class='" + classes + "'" + title + ">";
}, },
tinyAvatar: function(avatarTemplate, options) { tinyAvatar: function(avatarTemplate, options) {

View File

@ -17,15 +17,15 @@ describe PrettyText do
end end
it "produces a quote even with new lines in it" do it "produces a quote even with new lines in it" do
expect(PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"]ddd\n[/quote]")).to match_html "<aside class=\"quote\" data-post=\"123\" data-topic=\"456\" data-full=\"true\"><div class=\"title\">\n<div class=\"quote-controls\"></div>\n<img width=\"20\" height=\"20\" src=\"//test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png\" class=\"avatar\">EvilTrout:</div>\n<blockquote><p>ddd</p></blockquote></aside>" expect(PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"]ddd\n[/quote]")).to match_html "<aside class=\"quote\" data-post=\"123\" data-topic=\"456\" data-full=\"true\"><div class=\"title\">\n<div class=\"quote-controls\"></div>\n<img alt='' width=\"20\" height=\"20\" src=\"//test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png\" class=\"avatar\">EvilTrout:</div>\n<blockquote><p>ddd</p></blockquote></aside>"
end end
it "should produce a quote" do it "should produce a quote" do
expect(PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"]ddd[/quote]")).to match_html "<aside class=\"quote\" data-post=\"123\" data-topic=\"456\" data-full=\"true\"><div class=\"title\">\n<div class=\"quote-controls\"></div>\n<img width=\"20\" height=\"20\" src=\"//test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png\" class=\"avatar\">EvilTrout:</div>\n<blockquote><p>ddd</p></blockquote></aside>" expect(PrettyText.cook("[quote=\"EvilTrout, post:123, topic:456, full:true\"]ddd[/quote]")).to match_html "<aside class=\"quote\" data-post=\"123\" data-topic=\"456\" data-full=\"true\"><div class=\"title\">\n<div class=\"quote-controls\"></div>\n<img alt='' width=\"20\" height=\"20\" src=\"//test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png\" class=\"avatar\">EvilTrout:</div>\n<blockquote><p>ddd</p></blockquote></aside>"
end end
it "trims spaces on quote params" do it "trims spaces on quote params" do
expect(PrettyText.cook("[quote=\"EvilTrout, post:555, topic: 666\"]ddd[/quote]")).to match_html "<aside class=\"quote\" data-post=\"555\" data-topic=\"666\"><div class=\"title\">\n<div class=\"quote-controls\"></div>\n<img width=\"20\" height=\"20\" src=\"//test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png\" class=\"avatar\">EvilTrout:</div>\n<blockquote><p>ddd</p></blockquote></aside>" expect(PrettyText.cook("[quote=\"EvilTrout, post:555, topic: 666\"]ddd[/quote]")).to match_html "<aside class=\"quote\" data-post=\"555\" data-topic=\"666\"><div class=\"title\">\n<div class=\"quote-controls\"></div>\n<img alt='' width=\"20\" height=\"20\" src=\"//test.localhost/uploads/default/avatars/42d/57c/46ce7ee487/40.png\" class=\"avatar\">EvilTrout:</div>\n<blockquote><p>ddd</p></blockquote></aside>"
end end
end end

View File

@ -137,15 +137,15 @@ test("avatarImg", function() {
var avatarTemplate = "/path/to/avatar/{size}.png"; var avatarTemplate = "/path/to/avatar/{size}.png";
equal(utils.avatarImg({avatarTemplate: avatarTemplate, size: 'tiny'}), equal(utils.avatarImg({avatarTemplate: avatarTemplate, size: 'tiny'}),
"<img width='20' height='20' src='/path/to/avatar/40.png' class='avatar'>", "<img alt='' width='20' height='20' src='/path/to/avatar/40.png' class='avatar'>",
"it returns the avatar html"); "it returns the avatar html");
equal(utils.avatarImg({avatarTemplate: avatarTemplate, size: 'tiny', title: 'evilest trout'}), equal(utils.avatarImg({avatarTemplate: avatarTemplate, size: 'tiny', title: 'evilest trout'}),
"<img width='20' height='20' src='/path/to/avatar/40.png' class='avatar' title='evilest trout'>", "<img alt='' width='20' height='20' src='/path/to/avatar/40.png' class='avatar' title='evilest trout'>",
"it adds a title if supplied"); "it adds a title if supplied");
equal(utils.avatarImg({avatarTemplate: avatarTemplate, size: 'tiny', extraClasses: 'evil fish'}), equal(utils.avatarImg({avatarTemplate: avatarTemplate, size: 'tiny', extraClasses: 'evil fish'}),
"<img width='20' height='20' src='/path/to/avatar/40.png' class='avatar evil fish'>", "<img alt='' width='20' height='20' src='/path/to/avatar/40.png' class='avatar evil fish'>",
"it adds extra classes if supplied"); "it adds extra classes if supplied");
blank(utils.avatarImg({avatarTemplate: "", size: 'tiny'}), blank(utils.avatarImg({avatarTemplate: "", size: 'tiny'}),