File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
packages/svelte/test/runtime/samples/attribute-custom-element-inheritance Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change
1
+ export default {
2
+ skip_if_ssr : true ,
3
+ skip_if_hydrate : true ,
4
+ html : `
5
+ <my-custom-element>Hello World!</my-custom-element>
6
+ `
7
+ } ;
Original file line number Diff line number Diff line change
1
+ <script >
2
+ class MyCustomElement extends HTMLElement {
3
+ constructor () {
4
+ super ();
5
+ this ._obj = null ;
6
+ this ._text = null ;
7
+ }
8
+
9
+ set text (text ) {
10
+ this ._text = text;
11
+ this .render ();
12
+ }
13
+
14
+ set camelCase (obj ) {
15
+ this ._obj = obj;
16
+ this .render ();
17
+ }
18
+
19
+ connectedCallback () {
20
+ this .render ();
21
+ }
22
+
23
+ render () {
24
+ this .innerHTML = ' Hello ' + this ._obj .text + this ._text ;
25
+ }
26
+ }
27
+
28
+ class Extended extends MyCustomElement {}
29
+
30
+ window .customElements .define (' my-custom-element' , Extended);
31
+ </script >
32
+
33
+ <my-custom-element camelCase ={{ text : ' World' }} text =" !" />
You can’t perform that action at this time.
0 commit comments