@@ -528,21 +528,19 @@ class ChatContainer extends LightElement {
528528
529529// ------- Register custom elements and shiny bindings ---------
530530
531- if ( ! customElements . get ( CHAT_MESSAGE_TAG ) ) {
532- customElements . define ( CHAT_MESSAGE_TAG , ChatMessage ) ;
533- }
534- if ( ! customElements . get ( CHAT_USER_MESSAGE_TAG ) ) {
535- customElements . define ( CHAT_USER_MESSAGE_TAG , ChatUserMessage ) ;
536- }
537- if ( ! customElements . get ( CHAT_MESSAGES_TAG ) ) {
538- customElements . define ( CHAT_MESSAGES_TAG , ChatMessages ) ;
539- }
540- if ( ! customElements . get ( CHAT_INPUT_TAG ) ) {
541- customElements . define ( CHAT_INPUT_TAG , ChatInput ) ;
542- }
543- if ( ! customElements . get ( CHAT_CONTAINER_TAG ) ) {
544- customElements . define ( CHAT_CONTAINER_TAG , ChatContainer ) ;
545- }
531+ const chatCustomElements = [
532+ { tag : CHAT_MESSAGE_TAG , component : ChatMessage } ,
533+ { tag : CHAT_USER_MESSAGE_TAG , component : ChatUserMessage } ,
534+ { tag : CHAT_MESSAGES_TAG , component : ChatMessages } ,
535+ { tag : CHAT_INPUT_TAG , component : ChatInput } ,
536+ { tag : CHAT_CONTAINER_TAG , component : ChatContainer }
537+ ] ;
538+
539+ chatCustomElements . forEach ( ( { tag, component } ) => {
540+ if ( ! customElements . get ( tag ) ) {
541+ customElements . define ( tag , component ) ;
542+ }
543+ } ) ;
546544
547545window . Shiny . addCustomMessageHandler (
548546 "shinyChatMessage" ,
0 commit comments