Skip to content

Conversation

@botandrose
Copy link
Collaborator

@botandrose botandrose commented Oct 17, 2025

Background

Idiomorph relies on ids being unique within the morphed document for two main reasons:

  1. It knows how to match up the old and new content
  2. It ensure elements with hidden state are reused, and thus retain their hidden state.

Problem

It's not easy to know when your html documents have duplicate ids, and resultant failures in the morph may be subtle or non-obvious in cause. It would likely take a deep dive into Idiomorph's algorithm with a debugger to identify that the problem is duplicate ids.

Proposition

Idiomorph already knows on startup when you have duplicate ids, so this PR simply prints a warning to the console with a list of them, leaving it up to the user to decide to either address or ignore. I've tried to make the message generic, so that vicarious users of Idiomorph (e.g. Turbo) who may have never heard it can still understand what the problem is, and what to do.

Questions

  1. Do we want to add some kind of option for users to disable this warning?
  2. Can we improve the warning message? Maybe link to a document explaining the issue in more detail?
  3. Any reason not to do this?

Closes #141

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Warn when duplicate ids detected

3 participants