File tree Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Expand file tree Collapse file tree 1 file changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -43,14 +43,21 @@ class Elroid {
43
43
}
44
44
} ) ;
45
45
}
46
+
47
+ update ( data ) {
48
+ Object . assign ( this . data , data ) ;
49
+ const compiledTemplate = this . compileTemplate ( this . template ) ;
50
+ this . el . innerHTML = compiledTemplate ;
51
+ this . bindEvents ( ) ;
52
+ }
46
53
}
47
54
48
- // Component
55
+ // Elroid Component
49
56
class ElComponent {
50
57
constructor ( options ) {
51
58
this . template = options . template ;
52
59
this . data = options . data ;
53
- this . el = document . createElement ( 'div' ) ;
60
+ this . el = document . querySelector ( options . el ) ;
54
61
55
62
this . compile ( ) ;
56
63
this . bindEvents ( ) ;
@@ -77,14 +84,20 @@ class ElComponent {
77
84
if ( method && typeof method === 'function' ) {
78
85
element . addEventListener ( 'click' , ( ) => {
79
86
method . bind ( this . data ) ( ) ;
80
- this . compile ( ) ;
81
- this . bindEvents ( ) ;
82
87
} ) ;
83
88
}
84
89
} ) ;
85
90
}
91
+
92
+ update ( data ) {
93
+ Object . assign ( this . data , data ) ;
94
+ const compiledTemplate = this . compileTemplate ( this . template ) ;
95
+ this . el . innerHTML = compiledTemplate ;
96
+ this . bindEvents ( ) ;
97
+ }
86
98
}
87
99
100
+ // Elroid Request
88
101
class ElRequest {
89
102
constructor ( ) {
90
103
this . http = new XMLHttpRequest ( ) ;
You can’t perform that action at this time.
0 commit comments