Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/BootstrapBlazor/BootstrapBlazor.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Razor">

<PropertyGroup>
<Version>10.4.2-beta01</Version>
<Version>10.4.2-beta02</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
6 changes: 3 additions & 3 deletions src/BootstrapBlazor/wwwroot/modules/utility.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import EventHandler from "./event-handler.js"
import EventHandler from "./event-handler.js"

const vibrate = () => {
if ('vibrate' in window.navigator) {
Expand Down Expand Up @@ -420,14 +420,14 @@ const drag = (element, start, move, end) => {
element.addEventListener('touchstart', handleDragStart)
}

const getDescribedElement = (element, selector = 'aria-describedby') => {
const getDescribedElement = (element, selector = 'aria-describedby', all = false) => {
if (isElement(element)) {
let id = element.getAttribute(selector)
if (id) {
if (id.indexOf('.') === -1) {
id = `#${id}`
}
return document.querySelector(id)
return all ? document.querySelectorAll(id) : document.querySelector(id)
Comment on lines +423 to +430
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

issue: Handling multiple aria-describedby IDs with all is likely incorrect with the current selector construction.

With all = true, this now does querySelectorAll(id), but aria-describedby often holds a space-separated list of IDs (e.g. "id1 id2"). That makes id become "#id1 id2", which is parsed as a descendant selector, not multiple IDs, so it won’t reliably return all referenced elements. If all is meant to return all described elements, you likely need to split on whitespace, prefix each with #, and either build a comma-separated selector for querySelectorAll or use getElementById per ID and aggregate the results.

}
}
Copy link

Copilot AI Mar 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

getDescribedElement now returns different types depending on all (Element vs NodeList vs null). This makes the API easy to misuse (e.g., if (ret) ret.querySelector(...) works for Element but breaks for NodeList; also querySelectorAll returns an empty NodeList which is truthy, while the function otherwise returns null). Consider keeping the return type consistent: either split into getDescribedElement (single) + getDescribedElements (all), or when all=true always return a (possibly empty) array/NodeList and never null, and document the contract clearly for callers.

Suggested change
}
}
if (all) {
// Always return a NodeList for the "all" mode, even when there is no match,
// to mirror querySelectorAll semantics and keep the return type consistent.
return document.querySelectorAll('[data-utility-empty-aria-describedby=""]')
}

Copilot uses AI. Check for mistakes.
return null
Expand Down
Loading