@@ -528,21 +528,19 @@ class ChatContainer extends LightElement {
528
528
529
529
// ------- Register custom elements and shiny bindings ---------
530
530
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
+ } ) ;
546
544
547
545
window . Shiny . addCustomMessageHandler (
548
546
"shinyChatMessage" ,
0 commit comments