HighlightRegistry: forEach() Methode
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Die forEach()
-Methode der Schnittstelle HighlightRegistry
führt eine bereitgestellte Funktion einmal für jedes Highlight
-Objekt im Registry in der Einfügereihenfolge aus.
HighlightRegistry
ist ein Map
-ähnliches Objekt, daher ist dies ähnlich wie die Verwendung von Map.forEach()
.
Syntax
forEach(callbackFn)
forEach(callbackFn, thisArg)
Parameter
Rückgabewert
Keiner (undefined
).
Beispiele
Das folgende Codebeispiel zeigt, wie ein neues Highlight mit zwei Bereichen erstellt wird und dann die Bereiche mithilfe der forEach()
-Methode protokolliert werden:
function logAllHighlights(highlight, name) {
console.log(`Highlight ${name} exists in the registry`, highlight);
}
const customHighlight1 = new Highlight();
const customHighlight2 = new Highlight();
const customHighlight3 = new Highlight();
CSS.highlights.set("custom-highlight-1", customHighlight1);
CSS.highlights.set("custom-highlight-2", customHighlight2);
CSS.highlights.set("custom-highlight-3", customHighlight3);
CSS.highlights.forEach(logAllHighlights);
Spezifikationen
Specification |
---|
ECMAScript® 2025 Language Specification # sec-map.prototype.foreach |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
forEach |
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.