¿Qué causa el siguiente problema a continuación? ¿Alguna idea chicos? Gracias. el problema está en clone = thead.cloneNode(true);
Al tipo 'Nodo' le faltan las siguientes propiedades del tipo 'HTMLElement': accessKey, accessKeyLabel, autocapitalize, dir y 227 más.
También tengo un problema con Cannot read properties of null (reading 'getBoundingClientRect')
En realidad, estoy usando angular, pero hay algunas cosas personalizadas que debo hacer, por eso estoy haciendo este manual de JS.
#fragmento de código
let container = document.querySelector('#properties-content-left-container'); container.addEventListener("scroll", () => { let filterChips = document.querySelector('#properties-filter-chips'); let filterChipsBB = filterChips.getBoundingClientRect(); let top = filterChipsBB.top + filterChipsBB.height; let table = document.querySelector('#table') as HTMLElement | null; let tableBB = table.getBoundingClientRect(); let thead = table.querySelector('thead:not(.temporary)') as HTMLElement | null;; let gridContainer = document.querySelector('.grid-container'); let clone = table.querySelector('thead.temporary') as HTMLElement | null; table.style.position = 'relative'; if (tableBB.top < top) { if (thead.style.position != 'fixed') { thead.style.position = 'fixed'; thead.style.top = top + 'px'; thead.style.width = (gridContainer ? gridContainer.clientWidth : table.clientWidth) + 'px'; thead.style.maxWidth = (gridContainer ? gridContainer.clientWidth : table.clientWidth) + 'px'; thead.style.overflowX = 'auto'; } if (!clone) { clone = thead.cloneNode(true); clone.classList.add('temporary'); clone.style.opacity = '0'; clone.style.top = '0'; clone.style.position = 'sticky'; clone.style.width = 'auto'; clone.style.maxWidth = 'unset'; table.prepend(clone); }Para la primera pregunta, use la aserción de tipo para decirle al compilador que el nodo es en realidad un HTMLElement
clone = thead.cloneNode(true) as HTMLElement Para la segunda pregunta, verifique si filterChips o table son nulos. Use depurador/consola para eso.