This repository contains compatibility data for Web technologies.
Browser compatibility data describes which platforms (where "platforms" are
usually, but not always, web browsers) support particular Web APIs.
This data can be used in documentation, to build compatibility tables listing
browser support for APIs. For example:
Browser support for WebExtension APIs.
Once you have imported BCD, you can access the compatibility data for any feature by accessing the properties of the dictionary.
// Grab the desired support statementconstsupport=bcd.css.properties.background.__compat;// returns a compat data object (see schema)// You may use any syntax to obtain dictionary itemsconstsupport=bcd['api']['Document']['body']['__compat'];
Package contents
The @mdn/browser-compat-data package contains a tree of objects, with support and browser data objects at their leaves. There are over 12,000 features in the dataset; this documentation highlights significant portions, but many others exist at various levels of the tree.
The definitive description of the format used to represent individual features and browsers is the schema definitions.
Apart from the explicitly documented objects below, feature-level support data may change at any time. See Semantic versioning policy for details.
The package contains the following top-level objects:
The schema definitions for browser and support data structures
The TypeScript definitions
The details of browser compatibility change frequently, as browsers ship new features, standards organizations revise specifications, and Web developers discover new bugs. We routinely publish updates to the package to reflect these changes.
You should expect lower-level namespaces, feature data, and browser data to be added, removed, or modified at any time. That said, we strive to communicate changes and preserve backward compatibility; if you rely on a currently undocumented portion of the package and want SemVer to apply to it, please open an issue.
Here are some projects using the data, as an npm module or directly:
Add-ons Linter - the Add-ons Linter is used on addons.mozilla.org and the web-ext tool. It uses browser-compat-data to check that the Firefox version that the add-on lists support for does in fact support the APIs used by the add-on.
caniuse - In addition to the existing caniuse database, caniuse includes features from the MDN BCD project, formatted and interactive like any other caniuse support table.
CanIUse Embed - Thanks to the inclusion of MDN BCD data in caniuse, this embed tool allows for embedding BCD data into any project.
Compat Report - Firefox Add-on that shows compatibility data for the current site in the developer tools.
compat-tester - Scan local documents for compatibility issues.
请发表评论