DEV: Add data-topic-id to more elements containing titles.

This commit is contained in:
Dan Ungureanu
2018-11-04 11:23:45 +02:00
committed by Sam
parent 8837fe47d7
commit 1f9f00a629
6 changed files with 18 additions and 7 deletions
@@ -40,6 +40,7 @@ export default createWidget("header-topic-info", {
className: "topic-link",
action: "jumpToTopPost",
href,
attributes: { "data-topic-id": topic.get("id") },
contents: () => titleHTML
})
);
@@ -35,12 +35,18 @@ export default createWidget("link", {
},
buildAttributes(attrs) {
return {
const ret = {
href: this.href(attrs),
title: attrs.title
? I18n.t(attrs.title, attrs.titleOptions)
: this.label(attrs)
};
if (attrs.attributes) {
Object.keys(attrs.attributes).forEach(
k => (ret[k] = attrs.attributes[k])
);
}
return ret;
},
label(attrs) {
@@ -464,7 +464,11 @@ createWidget("post-article", {
},
buildAttributes(attrs) {
return { "data-post-id": attrs.id, "data-user-id": attrs.user_id };
return {
"data-post-id": attrs.id,
"data-topic-id": attrs.topicId,
"data-user-id": attrs.user_id
};
},
html(attrs, state) {