-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Provide an API for querying BCD data #4106
Comments
I'd love to see some reusable query APIs become part of the project! This may be a bit too much to have in BCD directly, but I wanted to share that we created a higher-level wrapper in Currently these helpers support querying for HTML and CSS features, including support for Examples: // Check if `<details>` is supported in both "chrome 74" and "ie 11"
isSupported({ element: 'details' }, ['chrome 74', 'ie 11']); // returns `false`
getUnsupported({ element: 'details' }, ['chrome 74', 'ie 11']); // returns `['ie 11']`
// Check if the HTML `hidden` attribute is supported in "firefox 65"
isSupported({ attribute: 'hidden' }, ['firefox 65']); // returns `true`
getUnsupported({ attribute: 'hidden' }, ['firefox 65']); // returns `null`
// Check if CSS alpha hex values are supported
isSupported({ property: 'color', value: '#00FF00FF' }, browsers);
// Check if CSS 3D transforms are supported
getUnsupported({ property: 'transform', value: 'translate3d(0, 0, 10px)' }, browsers); |
Thanks @antross, this is awesome feedback! 👍 I could imagine us supporting such a querying API as part of this project.
Do you have more insights into this process? Would you mind commenting any findings you had on |
@Elchi3 We didn't run into any new differences in the schemas between the Once we had the helper, the conversion itself was fairly easy since we were only using the |
I think that this was resolved when #6585 was, so I'm going to go ahead and close this. |
Summary: BCD itself should provide an API for querying data with strings that contain dotted paths and raise useful looking errors for missing or non-existent data.
A common pattern for contributors and consumers of BCD is to use a dotted path to reference features. Some of these features are valid identifiers that can be used with the BCD package. For example,
display
can be referred to ascss.properties.display
and the JavaScript codebcd.css.properties.display
gets the expected feature data (assuming you've runconst bcd = require('mdn-browser-compat-data')
).Other features have names which break this way of accessing data. For example,
bcd.css.properties.margin-top
doesn't work (you'd have to dobcd.css.properties['margin-top']
instead).Some BCD consumers have implemented some variation on this function:
We should provide a tested and documented query API instead, so consumers can query the data without reinventing this function each time.
The text was updated successfully, but these errors were encountered: