rendered
isn't a valid attribute for a HTML element, check the
Element - Web APIs | MDN[
^] documentation page.
If this is a custom attribute then you should probably prefix it with
data-
to indicate that it shouldn't be considered an actual DOM attribute, but a transient one. I also found
this StackOverflow link[
^] which indicates some attributes may be server-side and stripped before they reach the browser, in which case you wouldn't be able to access the attribute at all.
If you want to use the
data-
approach then you can add an attribute called
data-rendered="value"
and then access it using the
getAttribute()
method:
const element = document.getElementById('..');
if (element.hasAttribute('data-rendered'))
{
const rendered = element.getAttribute('data-rendered');
..
element.setAttribute('data-rendered', 'value');
}