@@ -13,6 +13,7 @@ import Attribute from './Attribute';
13
13
import Binding from './Binding' ;
14
14
import EventHandler from './EventHandler' ;
15
15
import Transition from './Transition' ;
16
+ import Animation from './Animation' ;
16
17
import Action from './Action' ;
17
18
import Text from './Text' ;
18
19
import * as namespaces from '../../utils/namespaces' ;
@@ -30,8 +31,9 @@ export default class Element extends Node {
30
31
actions : Action [ ] ;
31
32
bindings : Binding [ ] ;
32
33
handlers : EventHandler [ ] ;
33
- intro : Transition ;
34
- outro : Transition ;
34
+ intro ?: Transition ;
35
+ outro ?: Transition ;
36
+ animation ?: Animation ;
35
37
children : Node [ ] ;
36
38
37
39
ref : string ;
@@ -54,6 +56,7 @@ export default class Element extends Node {
54
56
55
57
this . intro = null ;
56
58
this . outro = null ;
59
+ this . animation = null ;
57
60
58
61
if ( this . name === 'textarea' ) {
59
62
// this is an egregious hack, but it's the easiest way to get <textarea>
@@ -113,6 +116,10 @@ export default class Element extends Node {
113
116
if ( node . outro ) this . outro = transition ;
114
117
break ;
115
118
119
+ case 'Animation' :
120
+ this . animation = new Animation ( compiler , this , scope , node ) ;
121
+ break ;
122
+
116
123
case 'Ref' :
117
124
// TODO catch this in validation
118
125
if ( this . ref ) throw new Error ( `Duplicate refs` ) ;
@@ -126,8 +133,6 @@ export default class Element extends Node {
126
133
}
127
134
} ) ;
128
135
129
- // TODO break out attributes and directives here
130
-
131
136
this . children = mapChildren ( compiler , this , scope , info . children ) ;
132
137
133
138
compiler . stylesheet . apply ( this ) ;
@@ -142,6 +147,10 @@ export default class Element extends Node {
142
147
this . cannotUseInnerHTML ( ) ;
143
148
}
144
149
150
+ this . var = block . getUniqueName (
151
+ this . name . replace ( / [ ^ a - z A - Z 0 - 9 _ $ ] / g, '_' )
152
+ ) ;
153
+
145
154
this . attributes . forEach ( attr => {
146
155
if ( attr . dependencies . size ) {
147
156
this . parent . cannotUseInnerHTML ( ) ;
@@ -180,19 +189,13 @@ export default class Element extends Node {
180
189
block . addDependencies ( handler . dependencies ) ;
181
190
} ) ;
182
191
183
- if ( this . intro ) {
184
- this . parent . cannotUseInnerHTML ( ) ;
185
- block . addIntro ( ) ;
186
- }
187
-
188
- if ( this . outro ) {
192
+ if ( this . intro || this . outro || this . animation || this . ref ) {
189
193
this . parent . cannotUseInnerHTML ( ) ;
190
- block . addOutro ( ) ;
191
194
}
192
195
193
- if ( this . ref ) {
194
- this . parent . cannotUseInnerHTML ( ) ;
195
- }
196
+ if ( this . intro ) block . addIntro ( ) ;
197
+ if ( this . outro ) block . addOutro ( ) ;
198
+ if ( this . animation ) block . addAnimation ( this . var ) ;
196
199
197
200
const valueAttribute = this . attributes . find ( ( attribute : Attribute ) => attribute . name === 'value' ) ;
198
201
@@ -229,10 +232,6 @@ export default class Element extends Node {
229
232
component . _slots . add ( slot ) ;
230
233
}
231
234
232
- this . var = block . getUniqueName (
233
- this . name . replace ( / [ ^ a - z A - Z 0 - 9 _ $ ] / g, '_' )
234
- ) ;
235
-
236
235
if ( this . children . length ) {
237
236
if ( this . name === 'pre' || this . name === 'textarea' ) stripWhitespace = false ;
238
237
this . initChildren ( block , stripWhitespace , nextSibling ) ;
0 commit comments