@@ -239,15 +239,21 @@ function configureStyleFromParameters(parameters: URLSearchParams): void {
239239 }
240240
241241 // Collect style properties to update them later with the bpmn-visualization API
242- // The implementation will be generalized when more properties will be supported (in particular, the query parameter name)
243- // For example, we could extract all query params starting with style.api, then rebuild the StyleUpdate from the extracted params
244- style = { stroke : { } , font : { } , fill : { } } ;
245-
246- parameters . get ( 'style.api.stroke.color' ) && ( style . stroke . color = parameters . get ( 'style.api.stroke.color' ) ) ;
247- parameters . get ( 'style.api.font.color' ) && ( style . font . color = parameters . get ( 'style.api.font.color' ) ) ;
248- parameters . get ( 'style.api.font.opacity' ) && ( style . font . opacity = Number ( parameters . get ( 'style.api.font.opacity' ) ) ) ;
249- parameters . get ( 'style.api.fill.color' ) && ( style . fill . color = parameters . get ( 'style.api.fill.color' ) ) ;
250- parameters . get ( 'style.api.fill.opacity' ) && ( style . fill . opacity = Number ( parameters . get ( 'style.api.fill.opacity' ) ) ) ;
242+ logStartup ( `Configuring the "Update Style" API from query parameters` ) ;
243+ // Only create the StyleUpdate object if some parameters are set
244+ if ( Array . from ( parameters . keys ( ) ) . filter ( key => key . startsWith ( 'style.api.' ) ) . length > 0 ) {
245+ style = { stroke : { } , font : { } , fill : { } } ;
246+
247+ parameters . get ( 'style.api.stroke.color' ) && ( style . stroke . color = parameters . get ( 'style.api.stroke.color' ) ) ;
248+ parameters . get ( 'style.api.font.color' ) && ( style . font . color = parameters . get ( 'style.api.font.color' ) ) ;
249+ parameters . get ( 'style.api.font.opacity' ) && ( style . font . opacity = Number ( parameters . get ( 'style.api.font.opacity' ) ) ) ;
250+ parameters . get ( 'style.api.fill.color' ) && ( style . fill . color = parameters . get ( 'style.api.fill.color' ) ) ;
251+ parameters . get ( 'style.api.fill.opacity' ) && ( style . fill . opacity = Number ( parameters . get ( 'style.api.fill.opacity' ) ) ) ;
252+
253+ logStartup ( `Prepared "Update Style" API object` , style ) ;
254+ } else {
255+ logStartup ( `No query parameters, do not set the "Update Style" API object` ) ;
256+ }
251257}
252258
253259function configureBpmnElementIdToCollapseFromParameters ( parameters : URLSearchParams ) : void {
0 commit comments