Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

151
Views
¿Por qué la declaración if ignora la expresión al eliminar los nodos DOM?

Probé todo tipo de soluciones para indexar una matriz y eliminar elementos que coincidan con una expresión regular. La solución con la que terminé debería funcionar, ya que no omite las iteraciones de bucle debido al cambio de longitud de la matriz, que es el problema que tenía antes. Sin embargo, ahora parece ignorar mi declaración if.

 const iframes = Array.from(document.getElementsByTagName("iframe")).filter(frame => frame.getAttribute("src") == "/domain/to/iframe"); const idoc = iframes.length === 1 ? iframes[0].contentWindow.document : document; const regex = /.*TextGoesHere*/sig; var msgs = idoc.getElementsByClassName("message"); msgs = Array.from(msgs); while (msgs.length > 0) { removal = msgs.pop(msgs.length); if (regex.test(removal.innerHTML)) { removal.remove(); } else { console.log(regex.test(removal.innerHTML)); } }

Producción:

 false false true true false false
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!