The ConstrainDOMString dictionary is used to specify a constraint for a property whose value is a string. It allows you to specify one or more exact string values from which one must be the parameter's value, or a set of ideal values which should be used if possible. You can also specify a single string (or an array of strings) which the user agent will do its best to match once all more stringent constraints have been applied.
Properties
The value of a ConstrainDOMString can be any of the following:
- A single
DOMString - An array of
DOMStringobjects - An object with one or both of the following properties:
exact- Either a single
DOMStringwhich must be the value of the property, or an array ofDOMStringobjects one of which must be the property's value. If the property can't be set to one of the listed values, matching will fail. ideal- Either a single
DOMStringor an array ofDOMStrings specifying ideal values for the property. If possible, one of the listed values will be used, but if it's not possible, the user agent will use the closest possible match.
Specifications
| Specification | Status | Comment |
| Media Capture and StreamsThe definition of 'ConstrainDOMString' in that specification. | Candidate Recommendation | Initial definition |
Technically, ConstrainDOMString is actually based on an intermediary dictionary named ConstrainDOMStringParameters, which adds exact and ideal to DOMString. However, for the sake of documentation clarity, the intermediate type (present only because of quirks in WebIDL syntax) is ignored here.
Browser compatibility
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
Update compatibility data on GitHub
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
ConstrainDOMString
|
Chrome
Full support Yes |
Edge
Full support ≤79 |
Firefox
Full support 50 |
IE
No support No |
Opera
Full support Yes |
Safari
? |
WebView Android
Full support Yes |
Chrome Android
Full support Yes |
Firefox Android
Full support 50 |
Opera Android
Full support Yes |
Safari iOS
? |
Samsung Internet Android
Full support Yes |
Legend
- Full support
- Full support
- No support
- No support
- Compatibility unknown
- Compatibility unknown
See also
- Media Capture and Streams API
- Capabilities, constraints, and settings
MediaTrackConstraintsMediaTrackCapabilitiesMediaTrackSupportedConstraints
ConstrainDOMString by Mozilla Contributors is licensed under CC-BY-SA 2.5.