id attribute in bs carousel on 5.3.2 doesn't accept numeric values
Prerequisites
- [X] I have searched for duplicate or closed issues
- [X] I have validated any HTML to avoid common problems
- [X] I have read the contributing guidelines
Describe the issue
I have a following shortcode in my project:
<!-- Carousel folder. Makes a carousel with every image inside the folder you've given as an inner argument-->
{{ $allImages := $.Page.Resources.ByType "image" }}
{{ $imagesInFolder := $allImages.Match (printf "%s/*" .Inner) }}
{{ $carouselFID := .Get "id" | default "tigidik" }}
<div id="{{ $carouselFID }}" class="carousel carousel-dark slide">
<div class="carousel-indicators" style="margin-bottom: -1rem !important;">
{{ range $index, $img := $imagesInFolder }}
<button type="button" data-bs-target="#{{ $carouselFID }}" data-bs-slide-to="{{ $index }}" {{ if eq $index 0 }}class="active" aria-current="true"{{ end }} aria-label="Slide {{ add $index 1 }}"></button>
{{ end }}
</div>
<div class="carousel-inner">
{{ range $index, $img := $imagesInFolder }}
{{ $img := $img.Resize "1200x q100 Lanczos" }}
{{ $img := $img.Fill "1200x900 q85 Lanczos" }} <!-- scaling and cropping to fit 1200x900 while maintaining original proportions -->
<div class="carousel-item {{ if eq $index 0 }}active{{ end }}">
<img src="{{ $img.RelPermalink }}" class="d-block w-100" loading="lazy" alt="carousel is broken">
<p class="dot-cs">
<b><a href="{{ $img }}">· </a></b>
</p>
</div>
{{ end }}
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#{{ $carouselFID }}" data-bs-slide="prev" style="left: -30px !important;">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#{{ $carouselFID }}" data-bs-slide="next" style="right: -30px !important;">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
This is a pretty much default bootstrap carousel with a bit of hugo html templating and custom styles.
After updating from 5.3.1 to 5.3.2 all my carousels stopped working. Buttons have become unresponsive.
I think I found a bug. Turns out, the carousel stops working if you assign a numeric value to div id= attribute. All my ids are numeric, so basically my whole website is broken on the 5.3.2 version. However, it worked on 5.3.1.
I checked it with codepen, and you can see a test case below.
<!-- in bootstrap 5.3.2 numeric id (666) breaks the carousel -->
<div id="666" class="carousel carousel-dark slide">
<div class="carousel-indicators">
<button type="button" data-bs-target="#666" data-bs-slide-to="0" class="active" aria-current="true" aria-label="Slide 1"></button>
<button type="button" data-bs-target="#666" data-bs-slide-to="1" aria-label="Slide 2"></button>
<button type="button" data-bs-target="#carouselExampleIndicators" data-bs-slide-to="2" aria-label="Slide 3"></button>
</div>
<div class="carousel-inner">
<div class="carousel-item active">
<img src="..." class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="..." class="d-block w-100" alt="...">
</div>
<div class="carousel-item">
<img src="..." class="d-block w-100" alt="...">
</div>
</div>
<button class="carousel-control-prev" type="button" data-bs-target="#666" data-bs-slide="prev">
<span class="carousel-control-prev-icon" aria-hidden="true"></span>
<span class="visually-hidden">Previous</span>
</button>
<button class="carousel-control-next" type="button" data-bs-target="#666" data-bs-slide="next">
<span class="carousel-control-next-icon" aria-hidden="true"></span>
<span class="visually-hidden">Next</span>
</button>
</div>
What operating system(s) are you seeing the problem on?
macOS
What browser(s) are you seeing the problem on?
Safari
What version of Bootstrap are you using?
5.3.2
Isn't that because HTML specs says that an ID should begin with a letter? https://www.w3.org/TR/html401/types.html#type-name
thank you! I discovered it too after I've filled the issue. So - my bad, I guess?
Still, the inconsistent behaviour of Bootstrap is confusing.
Hey,
Are we asked to do something here ? I can't see how to handle it properly ? Should we mention it in the migration guide or something ? Or maybe we can safely close this issue ?
It's up to you to decide. I'm not a competent person.
I think it's worth to be mentioned in a changelog for the last version, because this is where I've checked if the behaviour was changed.