twbs / twbs/bootstrap

Ability to disable `EventHandler` automatic listener assignments

Open
#39,301 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

feature js
Dominant language
MDX
Stars
175k
Forks
78.6k
Avg merge
7h 19m
Merged PRs (30d)
35

Description

Prerequisites
Proposal

Hey,

I was wondering why my uninitialized elements in my code — provided they have the data tags in place — get automatically initialized with the bootstrap modules I include somewhere else in my JS/TS code.

Then, after some debugging and tracing I figured it out: it's the EventHandler.on calls on the bottom of respective bootstrap module code.

I'd like to turn this off, but by looking at the code, right now I have no possibility of doing so.

The proposal is to be able to specify bootstrap that I will manually initialize my elements, and Bootstrap should not automatically do so by listening for various events on the document node.

Motivation and context

I am using webpack and typescript to bundle my modules together using the latest bootstrap with vanilla JS. Problem is, once I include one Bootstrap module somewhere (Modal or Collapse are fine examples of this), it automatically starts listening on elements that I didn't even specify it to listen on. This makes development a bit frustrating, as I like to have full control over where I initialize modules.

I don't want Bootstrap modules to take over elements I don't specifically specify. Testing gets really frustrating when I want to see the places I forgot to initialize stuff, and I don't want it to automatically happen by code I have no control over.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the EventHandler.on calls at the bottom of the Bootstrap module code, using Modal and Collapse as the examples mentioned in the issue. Determine how an opt-out for automatic document listeners would affect manual initialization and the other modules. Done should allow users to disable automatic assignments while preserving explicit module initialization.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, typescript, webpack
Domain
frontend, web-dev
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.