Skip to content

Commit d16c25a

Browse files
committed
compat-table: upstream update
1 parent fb39408 commit d16c25a

File tree

2 files changed

+37
-4
lines changed

2 files changed

+37
-4
lines changed

src/mdn/browser-compatibility-table/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
browser-compatibility-table
22
--------------
3-
This dir contains code rewritten from [mdn/yari](https://github.com/mdn/yari/blob/v4.9.0/client/src/lit/compat/), which is licensed [MPL-2.0](https://github.com/mdn/yari/blob/v0.4.123/LICENSE)
3+
This dir contains code rewritten from [mdn/yari](https://github.com/mdn/yari/blob/v4.11.0/client/src/lit/compat/), which is licensed [MPL-2.0](https://github.com/mdn/yari/blob/v0.4.123/LICENSE)
44

55
`types.ts` is [types.d.ts](https://unpkg.com/@mdn/[email protected]/types.d.ts) from [mdn/browser-compat-data](https://github.com/mdn/browser-compat-data), licensed [CC0](https://github.com/mdn/browser-compat-data/blob/v5.2.38/LICENSE)
66

src/mdn/browser-compatibility-table/compat-table.ts

Lines changed: 36 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,40 @@ export class CompatTable {
196196
_renderTableBody() {
197197
// <FeatureListAccordion>
198198
const { data, _browsers: browsers, browserInfo, locale } = this;
199-
const features = listFeatures(data, '', this._name);
199+
let features = listFeatures(data, '', this._name);
200+
201+
const MAX_FEATURES = 100;
202+
203+
// If there are too many features, hide nested features.
204+
if (features.length > MAX_FEATURES) {
205+
features = features.filter(({ depth }) => depth < 2);
206+
}
207+
208+
// If there are still too many features, hide non-standard features.
209+
if (features.length > MAX_FEATURES) {
210+
features = features.filter(
211+
({ compat: { status } }) => status?.standard_track
212+
);
213+
}
214+
215+
// If there are still too many features, hide deprecated features.
216+
if (features.length > MAX_FEATURES) {
217+
features = features.filter(
218+
({ compat: { status } }) => !status?.deprecated
219+
);
220+
}
221+
222+
// If there are still too many features, hide experimental features.
223+
if (features.length > MAX_FEATURES) {
224+
features = features.filter(
225+
({ compat: { status } }) => !status?.experimental
226+
);
227+
}
228+
229+
// At this point, we did all we can to reduce the number of features shown.
230+
if (features.length > MAX_FEATURES) {
231+
features = features.slice(0, MAX_FEATURES);
232+
}
200233

201234
return `<tbody>
202235
${features.map((feature) => {
@@ -609,12 +642,12 @@ export class CompatTable {
609642
<span
610643
class="bc-version-label"
611644
title="${browserReleaseDate && !timeline
612-
? `${browser.name} ${added}Released ${browserReleaseDate}`
645+
? `${browser.name} ${added}Release date: ${browserReleaseDate}`
613646
: ''}"
614647
>
615648
${!timeline || added ? label : ''}
616649
${browserReleaseDate && timeline
617-
? ` (Released ${browserReleaseDate})`
650+
? ` (Release date: ${browserReleaseDate})`
618651
: ''}
619652
</span>
620653
</div>

0 commit comments

Comments
 (0)