mirror of
https://github.com/ItsVipra/ProToots
synced 2024-11-25 21:10:19 +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}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
function getID(element) {
|
function getID(element) {
|
||||||
const id = element.dataset.id;
|
let id = element.dataset.id;
|
||||||
if (!id) {
|
if (!id) {
|
||||||
// We don't have a status ID, pronouns might not be in cache
|
// We don't have a status ID, pronouns might not be in cache
|
||||||
warn(
|
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,
|
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;
|
return id;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue