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
20 changes: 13 additions & 7 deletions src/core/caniuse.js
Original file line number Diff line number Diff line change
Expand Up @@ -195,22 +195,28 @@ function browserCellRenderer(feature) {
return (groups, { browser: browserId, version, caniuse }) => {
const entry = BROWSERS.get(browserId);
const { name, type } = entry ?? { name: browserId, type: "desktop" };
const versionLong = version ? ` version ${version}` : "";
const browserName = `${name}${versionLong}`;
const supportLevel = statToText.get(caniuse);
const ariaLabel = `${feature} is ${supportLevel} since ${browserName} on ${type}.`;
const cssClass = `caniuse-cell ${caniuse}`;
const title = capitalize(`${supportLevel} since ${browserName}.`);
const textVersion = version ? version : "—";
const versionSuffix = version
? ` version ${version}`
: " (version unknown)";
const ariaLabel = `${feature} is ${supportLevel} since ${name}${versionSuffix} on ${type}.`;
const cssClass = `caniuse-cell ${caniuse}`;
const title = capitalize(`${supportLevel} since ${name}${versionSuffix}.`);
const src = getLogoSrc(browserId);
const result = html`
<div class="${cssClass}" title="${title}" aria-label="${ariaLabel}">
<div
class="${cssClass}"
role="img"
title="${title}"
aria-label="${ariaLabel}"
>
Comment thread
marcoscaceres marked this conversation as resolved.
<img
class="caniuse-browser"
width="20"
height="20"
src="${src}"
alt="${name} logo"
alt=""
Comment thread
marcoscaceres marked this conversation as resolved.
/><span class="browser-version">${textVersion}</span>
Comment thread
marcoscaceres marked this conversation as resolved.
</div>
`;
Expand Down
12 changes: 11 additions & 1 deletion tests/spec/core/caniuse-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,11 @@ describe("Core — Can I Use", () => {

expect(firefox.width).toBe(20);
expect(firefox.height).toBe(20);
expect(chrome.alt).toBe("Android Chrome logo");
expect(chrome.alt).toBe("");

// The parent cell has role=img with aria-label for accessibility
const firstCell = cells[0];
expect(firstCell.getAttribute("role")).toBe("img");

// The version numbers
const [firefoxVersion, chromeVersion, safariVersion] =
Expand All @@ -112,6 +116,12 @@ describe("Core — Can I Use", () => {
expect(firefoxVersion.textContent).toBe("66");
expect(safariVersion.textContent).toBe("—");

// aria-label for no-version cell uses "(version unknown)" to match visible "—"
const safariCell = safariVersion.closest(".caniuse-cell");
expect(safariCell.getAttribute("aria-label")).toBe(
"FEATURE is unknown support since iOS Safari (version unknown) on mobile."
);

// More info link
const moreInfoLink = cells.item(3);
expect(moreInfoLink.href).toBe("https://caniuse.com/FEATURE");
Expand Down
Loading