diff --git a/.changeset/selfish-monkeys-crash.md b/.changeset/selfish-monkeys-crash.md new file mode 100644 index 0000000..c5373a3 --- /dev/null +++ b/.changeset/selfish-monkeys-crash.md @@ -0,0 +1,5 @@ +--- +'@flowbase-co/booster': minor +--- + +Prevent multiple initializations of Booster diff --git a/packages/booster/src/booster.ts b/packages/booster/src/booster.ts index 8b2b82d..105c390 100644 --- a/packages/booster/src/booster.ts +++ b/packages/booster/src/booster.ts @@ -6,6 +6,8 @@ import { type BoosterRecord, } from './types' +const BOOSTER_STATE_INITIALIZED = 'fb-booster-initialized' + export class Booster implements BoosterBase { @@ -93,6 +95,11 @@ export class Booster init() { const elements = this.getElements() - elements.forEach((el) => this.parse(el)) + elements.forEach((el) => { + if (el.hasAttribute(BOOSTER_STATE_INITIALIZED)) return + + el.setAttribute(BOOSTER_STATE_INITIALIZED, 'true') + this.parse(el) + }) } }