@@ -9,12 +9,10 @@ function createComponent(html) {
99 // Set text content
1010 function setContent ( cssSelector , content , shadow ) {
1111 const selector = shadow . querySelector ( cssSelector ) ;
12- // Check if p tag is used in desc
13- if ( content . includes ( '<p>' ) ) {
14- // Create paragraph element and add it to the document
15- let paragraph = document . createElement ( 'p' ) ;
16- paragraph . innerHTML = content ;
17- selector . appendChild ( paragraph ) ;
12+ // Check if span tag is used in desc
13+ if ( content . includes ( '<span>' ) ) {
14+ // Update HTML
15+ selector . innerHTML = content ;
1816 } else {
1917 // Update the text
2018 selector . textContent = content ;
@@ -49,7 +47,7 @@ function createComponent(html) {
4947
5048 // Return array of properties to observe
5149 static get observedAttributes ( ) {
52- return [ 'name' , 'section' , 'desc' , 'desc2' , 'linktext' , 'link' , 'linktext2' , 'link2' ] ;
50+ return [ 'name' , 'image' , ' section', 'desc' , 'desc2' , 'linktext' , 'link' , 'linktext2' , 'link2' ] ;
5351 }
5452
5553 // Called when an attribute is defined or changed
@@ -65,6 +63,7 @@ function createComponent(html) {
6563 shadow . innerHTML = html ;
6664
6765 // Set content
66+ setImage ( '.image' , this . image , shadow ) ;
6867 setContent ( '.section' , this . section , shadow ) ;
6968 setContent ( '.name' , this . name , shadow ) ;
7069 setContent ( '.desc' , this . desc , shadow ) ;
@@ -86,11 +85,9 @@ function createComponent(html) {
8685 switch ( this . section ) {
8786 case 'Engage' :
8887 heroSection . classList . add ( 'engage-bg' ) ;
89- setImage ( '.image' , 'wp-content/icons/icon_engage.svg' , shadow ) ;
9088 break ;
9189 case 'Learn' :
9290 heroSection . classList . add ( 'learn-bg' ) ;
93- setImage ( '.image' , 'wp-content/Icon_Managed ACBs_IMS DatabasePage.svg' , shadow ) ;
9491 break ;
9592 }
9693 }
0 commit comments