File tree Expand file tree Collapse file tree 1 file changed +21
-21
lines changed Expand file tree Collapse file tree 1 file changed +21
-21
lines changed Original file line number Diff line number Diff line change 2
2
< html >
3
3
< head >
4
4
< script type ="application/javascript ">
5
+ // Case 3: Visual component
5
6
6
- // Case 3: Visul component
7
+ class PageCaption extends HTMLElement {
8
+ constructor ( ) {
9
+ super ( ) ;
10
+ this . attachShadow ( { mode : "open" } ) ;
11
+ this . clicked = false ;
12
+ }
7
13
8
- class PageCaption extends HTMLElement {
9
- constructor ( ) {
10
- super ( ) ;
11
- this . attachShadow ( { mode : 'open' } ) ;
12
- this . clicked = false ;
13
- }
14
-
15
- connectedCallback ( ) {
16
- const html = `<h1>Marcus</h1><button type="button">Ave Marcus!</button>` ;
17
- this . shadowRoot . innerHTML = html ;
18
- this . shadowRoot . querySelector ( 'button' ) . addEventListener ( 'click' , ( ) => {
19
- if ( ! this . clicked ) {
20
- this . clicked = true ;
21
- const html = `<h1>Ave Marcus Aurelius!</h1>` ;
22
- this . shadowRoot . innerHTML = html ;
14
+ connectedCallback ( ) {
15
+ const html = `<h1>Marcus</h1><button type="button">Ave Marcus!</button>` ;
16
+ this . shadowRoot . innerHTML = html ;
17
+ this . shadowRoot
18
+ . querySelector ( "button" )
19
+ . addEventListener ( "click" , ( ) => {
20
+ if ( ! this . clicked ) {
21
+ this . clicked = true ;
22
+ const html = `<h1>Ave Marcus Aurelius!</h1>` ;
23
+ this . shadowRoot . innerHTML = html ;
24
+ }
25
+ } ) ;
26
+ }
23
27
}
24
- } ) ;
25
- }
26
- }
27
-
28
- window . customElements . define ( 'page-caption' , PageCaption ) ;
29
28
29
+ window . customElements . define ( "page-caption" , PageCaption ) ;
30
30
</ script >
31
31
</ head >
32
32
< body >
You can’t perform that action at this time.
0 commit comments