HighlightRegistry: delete() method
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
The delete()
method of the HighlightRegistry
interface removes a the named Highlight
object from the HighlightRegistry
.
HighlightRegistry
is a Map
-like object, so this is similar to using Map.delete()
.
Syntax
js
delete(customHighlightName)
Parameters
customHighlightName
-
The name, as a
String
, of theHighlight
object to remove from theHighlightRegistry
.
Return value
Returns true
if a Highlight
object under the provided name was in the HighlightRegistry
; otherwise false
.
Examples
The following code sample registers a highlight in the registry, and then deletes it:
js
const myHighlight = new Highlight(range1, range2);
CSS.highlights.set("my-highlight", myHighlight);
CSS.highlights.delete("foo"); // false
CSS.highlights.delete("my-highlight"); // true
Specifications
Specification |
---|
ECMAScript® 2025 Language Specification # sec-map.prototype.delete |
Browser compatibility
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
delete |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- In development. Supported in a pre-release version.
- In development. Supported in a pre-release version.
- No support
- No support
- See implementation notes.
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.