Код: Выделить всё
class LiveStats extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
this.shadowRoot.innerHTML = `
CO₂ Saved: 10kg
`;
}
updateCO2(newValue) {
const output = this.shadowRoot.getElementById("co2-output");
output.textContent = `CO₂ Saved: ${newValue}kg`;
}
}
customElements.define("live-stats", LiveStats);
Код: Выделить всё
output.textContent = "";
setTimeout(() => {
output.textContent = `CO₂ Saved: ${newValue}kg`;
}, 10);
Являются ли в живых регионах ARIA в Shadow Dom ненадежны, или есть еще один метод, чтобы гарантировать, что считыватели экрана постоянно читают динамические обновления?
Подробнее здесь: https://stackoverflow.com/questions/795 ... -a-web-com
Мобильная версия