thednp / bootstrap.native

Bootstrap components build with Typescript
http://thednp.github.io/bootstrap.native/
MIT License
1.7k stars 177 forks source link

Fix issue where null collapse throws a type error #401

Closed xHeinrich closed 3 years ago

xHeinrich commented 3 years ago

When compiled with typescript the following example from the documentation throws a type error because collapse is sometimes null:

<button id="collapseButton" class="btn btn-primary" type="button" aria-expanded="false" aria-controls="collapseExample"
  data-toggle="collapse" data-target="#collapseExample"> <!-- required DATA API -->
  Button with data-target
</button>

<!-- and the basic collapsible template -->
<div class="collapse" id="collapseExample">
  <div class="card card-body">
    ...
  </div>
</div>

let myCollapseInit = new BSN.Collapse('#collapseLink')
thednp commented 3 years ago

I've applied the fix to my local repository and will commit as soon as I finish, currently running some code cleanup. Thanks