spec_url propertyThe browser-compat-data project (BCD) uses the spec_url property to map compatibility data to features described in specifications.
The following spec_url guidelines give advice on how to provide good links to specifications. They are based on a discussion in #29582.
Maintaining pointers to specifications from BCD features provides several benefits:
spec_url is provided, BCD itself or other data consumers, can treat the feature as standardized. In the absence of a spec_url, we could say that the feature is non-standard.The spec_url property is defined and validated by the BCD JSON schema: It may be either a single URL or an array of URLs, each pointing to a specific part of a specification where the feature is defined.
The spec_url property is required if standard_track is set to true. However, currently, there is an exception list for this requirement. BCD maintainers are working through this backlog. It updates automatically when you add a URL to a feature that doesn't currently have a spec_url property.
Each URL must link to a specification published by a standards body or a formal proposal that may lead to such publication. To determine whether a specification host is valid, BCD relies on data from the w3c/browser-specs project.
If a specification is listed in browser-specs and has a standing of “good”, the URL will be accepted in BCD's spec_url field.
If BCD's linter complains about the provided URL, you will need to check its state within browser-specs. Common scenarios include:
https://tc39.es/proposal-promise-allSettled/#sec-promise.allsettled.#:~:text=).In addition to the validated rules above, the following best practices have emerged.
The spec_url property allows to take an array of multiple URLs, however, as a general guiding principle, provide just the single most meaningful URL. For example, don't add multiple (historical) versions of specifications.
If you find yourself in a situation where your BCD (behavioral) feature points to several URLs of a specification, this could actually be a strong hint that you should split up the feature into multiple BCD feature keys.
See below for cases where we actually recommend multiple URLs (events and specifications extending other specifications).
If a feature has been removed from a specification, this is a de facto deprecation (see Setting deprecated). If possible, set the feature's spec_url to point to current specification text that acknowledges the removal (for example, a Changes section).
For events, provide two URLs: one for the .onevent property definition, and one for the event itself.
"spec_url": [ "https://drafts.csswg.org/web-animations-1/#dom-animation-oncancel", "https://drafts.csswg.org/web-animations-1/#cancel-event" ],
When a specification extends the definition of another specification, it makes sense to list both as spec_urls. For example:
When the interface has “entries”, “forEach”, “get”, “has”, “keys”, “values”, “@@iterator” methods and a “size” getter via “maplike”, “setlike”, or “iterable” IDL constructs, link to the interface containing the definition and not to the IDL standard.
✅ "spec_url": "https://webaudio.github.io/web-audio-api/#audioparammap", ✅ "spec_url": "https://drafts.css-houdini.org/css-typed-om/#cssnumericarray", ❌ "spec_url": "https://webidl.spec.whatwg.org/#dfn-maplike", ❌ "spec_url": "https://webidl.spec.whatwg.org/#dfn-iterable",
WebIDL flags can map to certain BCD feature keys:
[SecureContext] uses secure_context_required[Exposed=Worker] (and similar) use worker_supportWebIDL flags belong to specific WebIDL features, like an interface or a method. The specifications offer no direct link to flag definitions, therefore the specification URL used for the feature itself should be used.
For example, if the [SecureContext] flag appears in front of an WebIDL interface definition, the spec_url for the secure_context_required feature is the same as the interface's spec_url.
"secure_context_required": { "__compat": { "description": "Secure context required", "spec_url": "https://w3c.github.io/battery/#the-batterymanager-interface",
If the [SecureContext] flag appears in front of an WebIDL method definition, use the spec_url for the method.
"secure_context_required": { "__compat": { "description": "Secure context required", "spec_url": "https://wicg.github.io/ua-client-hints/#dom-navigatorua-useragentdata",
Specification URLs are validated against webref IDs to make sure BCD only records features which are actually defined in the provided specification. Linking to text using #:~:text= fragment identifiers opts out of this validation. Use this opt-out rarely.