skip to Main Content

Why DOM is not updated when using CSS insertRule?

I want to add a CSS rule to the DOM: This is my code function empty_rule(sheet, class_name) { const index = sheet.cssRules.length; sheet.insertRule(`.${class_name} { }`, index); return sheet.cssRules[index]; } function make_style() { const $head = $('head'); const $style = $('<style…

VIEW QUESTION

Javascript – How can I prevent a DOM node removed from its tree from being held by spurious strong references, like from closures?

For a toy example, suppose I have a clock widget: { const clockElem = document.getElementById('clock'); const timefmt = new Intl.DateTimeFormat( 'default', { timeStyle: 'medium', }); setInterval(() => { const d = new Date; console.log('tick', d); clockElem.querySelector('p').innerHTML = timefmt.format(d); }, 1000);…

VIEW QUESTION
Back To Top
Search