Skip to content

fix: make plugin initialization idempotent for multiple imports#317

Open
dusan-maintains wants to merge 1 commit intokylefox:masterfrom
dusan-maintains:maintenance/no-double-init
Open

fix: make plugin initialization idempotent for multiple imports#317
dusan-maintains wants to merge 1 commit intokylefox:masterfrom
dusan-maintains:maintenance/no-double-init

Conversation

@dusan-maintains
Copy link

@dusan-maintains dusan-maintains commented Feb 27, 2026

Summary

  • add an initialization guard that returns early when jquery-modal is already attached
  • prevent duplicate plugin setup when the script is imported multiple times
  • keep the original modal instance state/event bindings intact

Why

Issue #309 reports breakage when jquery-modal is imported more than once. Re-initializing the plugin creates a fresh internal state that can desynchronize auto-close behavior from active modal instances.

Changes

  • jquery.modal.js

Test Plan

  • include jquery.modal.js twice and verify auto-close still works
  • include once and verify normal behavior remains unchanged

Compatibility

  • no API changes
  • idempotent guard only affects duplicate-load scenario

Closes #309

@dusan-maintains
Copy link
Author

Maintainer note: this addresses #309 by making initialization idempotent under duplicate imports. If there is a preferred guard condition/style, I can adjust quickly.

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.

Multiple imports of jquery modal

1 participant