Class ElementListenerMap
java.lang.Object
com.vaadin.flow.internal.nodefeature.NodeFeature
com.vaadin.flow.internal.nodefeature.NodeMap
com.vaadin.flow.internal.nodefeature.ElementListenerMap
- All Implemented Interfaces:
Serializable
Map of DOM events with server-side listeners. The key set of this map
describes the event types for which listeners are present. The values
associated with the keys are currently not used.
For internal use only. May be renamed or removed in a future release.
- Since:
- 1.0
- Author:
- Vaadin Ltd
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA function declared in the bundle, with the values it captures, that the client runs when an event occurs: a filter added withDomListenerRegistration.setFilterExpression(DomEventFilter)or event data added withDomListenerRegistration.addEventData(DomEventData).Nested classes/interfaces inherited from class com.vaadin.flow.internal.nodefeature.NodeMap
NodeMap.InternalSignalBinding -
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionElementListenerMap(StateNode node) Creates a new element listener map for the given node. -
Method Summary
Modifier and TypeMethodDescriptionadd(String eventType, DomEventListener listener) Add eventData for an event type.static voidaddBundledEventData(DomListenerRegistration registration, List<String> eventData) AddsEventDatavalues to a registration of this map likeaddEventData(DomListenerRegistration, List), for values that the build has put into the bundle as functions, seeBundledEventData.static voidaddEventData(DomListenerRegistration registration, List<String> eventData) Adds event data to a registration.static voidaddEventDataWithoutCspReport(DomListenerRegistration registration, List<String> eventData) Adds event data to a registration of this map likeaddEventData(DomListenerRegistration, List), but without reporting them as JavaScript sent as a string.voidcollectChanges(Consumer<NodeChange> collector) Collects all changes that are recorded for this feature.voidFires an event to all listeners registered for the given type.static StringgetEventDataKey(DomEventData<?> eventData) Gets the key that the client sends the value of the given event data under.getExpressions(String eventName) Gets the event data expressions defined for the given event name.getPropertySynchronizationMode(String propertyName) Gets the most permissive update mode for any event registration that is configured to synchronize the given property.getSnippetEntries(String eventName) Gets the declared snippets that the client runs for the given event name: the filters and the event data that are declared as JavaScript functions of the bundle instead of as expressions.booleanhasAllowInertForProperty(String propertyName) Returnstrueif any listener for the given property has allowInert enabled.static booleanisCompiledByClient(String eventData) Checks whether the client compiles the given event data from a string.static booleanisPropertyPath(String expression) Checks whether the given expression is a property path that the browser reads without compiling it:eventorelementfollowed by property names that each start with.or?.protected booleanproducePutChange(String key, boolean hadValueEarlier, Serializable newValue) Checks whether aMapPutChangeshould be produced.static voidsetBundledFilter(DomListenerRegistration registration, String filter) Sets aDomEvent.filter()that the build has put into the bundle as a function as the filter of a registration of this map, likeDomListenerRegistration.setFilter(String)but without reporting it as JavaScript sent as a string, seeBundledEventData.isBundledFilter(String).Methods inherited from class com.vaadin.flow.internal.nodefeature.NodeMap
bindSignal, clear, contains, forEachChild, generateChangesFromEmpty, get, getOrDefault, getOrDefault, getOrDefault, hasSignal, keySet, mayUpdateFromClient, put, put, remove, updateFromClientMethods inherited from class com.vaadin.flow.internal.nodefeature.NodeFeature
allowsChanges, attachPotentialChild, detatchPotentialChild, getNode, onAttach, onDetach
-
Field Details
-
ALWAYS_TRUE_FILTER
Dummy filter string that always passes. The client runs it without compiling it.- See Also:
-
-
Constructor Details
-
ElementListenerMap
Creates a new element listener map for the given node.- Parameters:
node- the node that the map belongs to
-
-
Method Details
-
isCompiledByClient
Checks whether the client compiles the given event data from a string. The client reads a synchronized property, the state node closest to the event target or a property path, also one that leads to the element to map to a state node, and callspreventDefault()orstopPropagation(), without compiling anything.- Parameters:
eventData- the event data, as passed toDomListenerRegistration.addEventData(String), notnull- Returns:
trueif the client compiles the event data withnew Function, which a content security policy withoutunsafe-evaldoes not allow- Since:
- 25.4
-
add
Add eventData for an event type.- Parameters:
eventType- the event typelistener- the listener to add- Returns:
- a handle for configuring and removing the listener
-
producePutChange
Description copied from class:NodeMapChecks whether aMapPutChangeshould be produced.- Overrides:
producePutChangein classNodeMap- Parameters:
key- a key to produce a changehadValueEarlier- whether the value was already earlier in the mapnewValue- the new value for thekey- Returns:
trueif a change should be produced,falseotherwise
-
collectChanges
Description copied from class:NodeFeatureCollects all changes that are recorded for this feature.- Overrides:
collectChangesin classNodeMap- Parameters:
collector- a consumer accepting node changes
-
fireEvent
Fires an event to all listeners registered for the given type.- Parameters:
event- the event to fire
-
getExpressions
Gets the event data expressions defined for the given event name. This method is currently only provided to facilitate unit testing.- Parameters:
eventName- the name of the event, notnull- Returns:
- an unmodifiable set of event data expressions, not
null - Since:
- 3.0
-
getSnippetEntries
Gets the declared snippets that the client runs for the given event name: the filters and the event data that are declared as JavaScript functions of the bundle instead of as expressions. Together withgetExpressions(String), this is everything the client runs when the event occurs. This method is currently only provided to facilitate testing, such as simulating events on the server.- Parameters:
eventName- the name of the event, notnull- Returns:
- an unmodifiable set of the declared snippets, not
null - Since:
- 25.4
-
isPropertyPath
Checks whether the given expression is a property path that the browser reads without compiling it:eventorelementfollowed by property names that each start with.or?..- Parameters:
expression- the expression to check, notnull- Returns:
trueif the expression is a property path,falseotherwise- Since:
- 25.4
-
addEventData
Adds event data to a registration. Reports the event data that the browser compiles from a string, which is any data other than a property path or a token of the internal data that Flow adds, such as a synchronized property. Keeps the given list if it is unmodifiable and the registration has no event data yet, so that listeners that add the same data can share one list.A registration that is not one of this map gets each value with
DomListenerRegistration.addEventData(String).- Parameters:
registration- the registration to add the event data to, notnulleventData- the event data, notnulland not containingnull- Throws:
CspViolationException- in theCspMode.STRICTContent Security Policy mode, if any value is compiled by the browser- Since:
- 25.4
-
addEventDataWithoutCspReport
public static void addEventDataWithoutCspReport(DomListenerRegistration registration, List<String> eventData) Adds event data to a registration of this map likeaddEventData(DomListenerRegistration, List), but without reporting them as JavaScript sent as a string. For the keys of data that client code builds and sends withsendEventMessage, which the client never compiles.- Parameters:
registration- a registration returned byadd(String, DomEventListener), notnulleventData- the keys of the event data, notnulland not containingnull- Since:
- 25.4
-
addBundledEventData
public static void addBundledEventData(DomListenerRegistration registration, List<String> eventData) AddsEventDatavalues to a registration of this map likeaddEventData(DomListenerRegistration, List), for values that the build has put into the bundle as functions, seeBundledEventData. The client runs the function of the bundle instead of compiling the value, and sends the result under the value, so nothing is reported as JavaScript sent as a string.- Parameters:
registration- a registration returned byadd(String, DomEventListener), notnulleventData- the event data values, notnulland not containingnull- Since:
- 25.4
-
setBundledFilter
Sets aDomEvent.filter()that the build has put into the bundle as a function as the filter of a registration of this map, likeDomListenerRegistration.setFilter(String)but without reporting it as JavaScript sent as a string, seeBundledEventData.isBundledFilter(String). The client runs the function of the bundle instead of compiling the filter, and sends the result under the filter, soDomListenerRegistration.getFilter()returns the filter as before.- Parameters:
registration- a registration returned byadd(String, DomEventListener), notnullfilter- the filter, notnull
-
getEventDataKey
Gets the key that the client sends the value of the given event data under. The key does not change after the event data is created.- Parameters:
eventData- the event data, notnull- Returns:
- the key of the value, not
null - Since:
- 25.4
-
getPropertySynchronizationMode
Gets the most permissive update mode for any event registration that is configured to synchronize the given property.- Parameters:
propertyName- the property name to check, notnull- Returns:
- the most permissive update mode, or
nullif synchronization is not configured for the given property - Since:
- 1.3
-
hasAllowInertForProperty
Returnstrueif any listener for the given property has allowInert enabled. Note that this means that enabling allowInert for any listener for a certain property will effectively allow it for all listeners for said property.- Parameters:
propertyName- the property name to check, notnull- Returns:
trueif allowInert is enabled for any listener for the given property,false otherwise- Since:
- 24.6.8
-