Skip to content

Commit 9c13a1b

Browse files
committed
Fix BCD search by going into the entry’s subentry
1 parent 6c0796e commit 9c13a1b

File tree

1 file changed

+17
-17
lines changed

1 file changed

+17
-17
lines changed

index.js

+17-17
Original file line numberDiff line numberDiff line change
@@ -408,28 +408,28 @@ const findResult = function findResult(name) {
408408
// Check BCD
409409
let bcdResults = [];
410410
for (const section of Object.keys(bcd).filter(k => !k.startsWith('__'))) { // css, js, html, …
411-
for (const [subsectionKey, subsection] of Object.entries(bcd[section])) { // at-rules, properties, …
412-
for (const [entryKey, entry] of Object.entries(subsection)) {
413-
if (entryKey == '__compat') {
414-
if (subsectionKey === name || entry.description?.includes(name)) {
415-
bcdResults.push({
416-
key: `mdn-${section}_${subsectionKey}`,
417-
data: entry
418-
});
419-
}
420-
} else {
421-
if (entryKey === name || entry['__compat']?.description?.includes(name)) {
422-
bcdResults.push({
423-
key: `mdn-${section}_${subsectionKey}_${entryKey}`,
424-
data: entry['__compat']
425-
});
411+
for (const [subsectionKey, subsection] of Object.entries(bcd[section])) { // css: at-rules, properties, …
412+
for (const [entryKey, entry] of Object.entries(subsection)) { // properties: writing_mode, word-wrap, …
413+
for (const [subEntryKey, subEntry] of Object.entries(entry)) { // writing-mode: __compat, horizontal-tb, lr, lr-tb, …
414+
if (subEntryKey == '__compat') {
415+
if (entryKey === name || entry['__compat'].description?.includes(name)) {
416+
bcdResults.push({
417+
key: `mdn-${section}_${subsectionKey}_${entryKey}`,
418+
data: subEntry
419+
});
420+
}
421+
} else {
422+
if (subEntryKey === name || subEntry['__compat']?.description?.includes(name)) {
423+
bcdResults.push({
424+
key: `mdn-${section}_${subsectionKey}_${entryKey}_${subEntryKey}`,
425+
data: subEntry['__compat']
426+
});
427+
}
426428
}
427429
}
428430
}
429431
}
430432
}
431-
432-
// @TODO: Convert BCD format to CanIUse format
433433
bcdResults = bcdResults.map(bcdResult => convertBCDEntryToCanIUseEntry(bcdResult.key, bcdResult.data));
434434

435435
// return array of matches

0 commit comments

Comments
 (0)