mirror of
https://github.com/ItsVipra/ProToots
synced 2024-11-25 13:00:18 +00:00
search closest article, if element doesn't have an id
This commit is contained in:
parent
f726843809
commit
ff78899cc7
1 changed files with 7 additions and 2 deletions
|
@ -215,13 +215,18 @@ async function addProplate(element) {
|
|||
* @returns {string}
|
||||
*/
|
||||
function getID(element) {
|
||||
const id = element.dataset.id;
|
||||
let id = element.dataset.id;
|
||||
if (!id) {
|
||||
// We don't have a status ID, pronouns might not be in cache
|
||||
warn(
|
||||
"The element passed to addProplate does not have a data-id attribute, although it should have one.",
|
||||
"The element passed to addProplate does not have a data-id attribute, searching for article.",
|
||||
element,
|
||||
);
|
||||
//if we couldn't get an id from the div try the closest article
|
||||
const ArticleElement = element.closest("article");
|
||||
if (ArticleElement) {
|
||||
id = getID(ArticleElement);
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue