HighlightRegistry: has() method
MDN Web Docs · نسخهٔ df622a2a1c1e · CC BY-SA 2.5 و مجوز جداگانهٔ ناشر برای نمونهکد
{{APIRef("CSS Custom Highlight API")}}
The **has()** method of the {{domxref("HighlightRegistry")}} interface returns a boolean indicating whether or not a {{domxref("Highlight")}} object with the specified name exists in the registry.
HighlightRegistry is a {{jsxref("Map")}}-like object, so this is similar to using {{jsxref("Map.has()")}}.
Syntax
js-nolint
has(name)Parameters
name- : The name of the
Highlightobject to test for presence in the registry.
Return value
Returns true if a highlight with the specified name exists in the registry; otherwise false.
Examples
js
const fooHighlight = new Highlight();
CSS.highlights.set("foo", fooHighlight);
myHighlight.has("foo"); // true
myHighlight.has("bar"); // falseSpecifications
{{Specifications}}
Browser compatibility
{{Compat}}
See also
- {{domxref("css_custom_highlight_api", "The CSS Custom Highlight API", "", "nocode")}}
- CSS Custom Highlight API: The Future of Highlighting Text Ranges on the Web