Skip to content

Detached word node → TypeError on null parentNode silently kills the polling chain; no public API to refresh wordArr after DOM edits #265

Description

@maboa

Summary

(As of v2.6.2.) wordArr holds live node references with no official rebuild method. In the visual-state updater (hyperaudio-lite.js:1036-1050):

const activeWord = index > 0 ? this.wordArr[index - 1].n : null;
const activeParent = activeWord ? activeWord.parentNode : null;
...
if (activeWord) {
  ...
  activeParent.classList.add('active');   // activeParent is null if activeWord is detached

Any consumer that edits the DOM (hyperaudio-lite-editor mutates spans continuously — word splitting, strike-through cuts) can leave wordArr[i].n.parentNode === null. The next tick throws inside the async setTimeout → checkPlayHead → checkStatus chain, the rejection is unhandled, and the timer is never re-armed — karaoke highlighting stops with no console-visible cause in production.

The editor already monkey-patches around this from outside (its editor-core.js filters wordArr post-hoc, referencing its own #294), which is exactly the sign the library needs to own the fix.

Fix

Guard activeParent for null before classList.add, and expose an official refreshWords() (rebuild wordArr/parentElements, reset prevWordIndex/activeWordElement) so editors don't have to reach into internals.

Found reviewing the copy vendored in hyperaudio-lite-editor / GliderMac (2026-07-11).

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions