@@ -111,30 +111,31 @@ function getAttributeType(attribute) {
111
111
if ( attribute . directive ) {
112
112
if ( ! isVBind ( attribute ) ) {
113
113
const name = attribute . key . name . name
114
- if ( name === 'for' ) {
115
- return ATTRS . LIST_RENDERING
116
- } else if (
117
- name === 'if' ||
118
- name === 'else-if' ||
119
- name === 'else' ||
120
- name === 'show' ||
121
- name === 'cloak'
122
- ) {
123
- return ATTRS . CONDITIONALS
124
- } else if ( name === 'pre' || name === 'once' ) {
125
- return ATTRS . RENDER_MODIFIERS
126
- } else if ( name === 'model' ) {
127
- return ATTRS . TWO_WAY_BINDING
128
- } else if ( name === 'on' ) {
129
- return ATTRS . EVENTS
130
- } else if ( name === 'html' || name === 'text' ) {
131
- return ATTRS . CONTENT
132
- } else if ( name === 'slot' ) {
133
- return ATTRS . SLOT
134
- } else if ( name === 'is' ) {
135
- return ATTRS . DEFINITION
136
- } else {
137
- return ATTRS . OTHER_DIRECTIVES
114
+ switch ( name ) {
115
+ case 'for' :
116
+ return ATTRS . LIST_RENDERING
117
+ case 'if' :
118
+ case 'else-if' :
119
+ case 'else' :
120
+ case 'show' :
121
+ case 'cloak' :
122
+ return ATTRS . CONDITIONALS
123
+ case 'pre' :
124
+ case 'once' :
125
+ return ATTRS . RENDER_MODIFIERS
126
+ case 'model' :
127
+ return ATTRS . TWO_WAY_BINDING
128
+ case 'on' :
129
+ return ATTRS . EVENTS
130
+ case 'html' :
131
+ case 'text' :
132
+ return ATTRS . CONTENT
133
+ case 'slot' :
134
+ return ATTRS . SLOT
135
+ case 'is' :
136
+ return ATTRS . DEFINITION
137
+ default :
138
+ return ATTRS . OTHER_DIRECTIVES
138
139
}
139
140
}
140
141
propName =
@@ -144,16 +145,19 @@ function getAttributeType(attribute) {
144
145
} else {
145
146
propName = attribute . key . name
146
147
}
147
- if ( propName === 'is' ) {
148
- return ATTRS . DEFINITION
149
- } else if ( propName === 'id' ) {
150
- return ATTRS . GLOBAL
151
- } else if ( propName === 'ref' || propName === 'key' ) {
152
- return ATTRS . UNIQUE
153
- } else if ( propName === 'slot' || propName === 'slot-scope' ) {
154
- return ATTRS . SLOT
155
- } else {
156
- return ATTRS . OTHER_ATTR
148
+ switch ( propName ) {
149
+ case 'is' :
150
+ return ATTRS . DEFINITION
151
+ case 'id' :
152
+ return ATTRS . GLOBAL
153
+ case 'ref' :
154
+ case 'key' :
155
+ return ATTRS . UNIQUE
156
+ case 'slot' :
157
+ case 'slot-scope' :
158
+ return ATTRS . SLOT
159
+ default :
160
+ return ATTRS . OTHER_ATTR
157
161
}
158
162
}
159
163
@@ -213,13 +217,13 @@ function create(context) {
213
217
214
218
/** @type { { [key: string]: number } } */
215
219
const attributePosition = { }
216
- attributeOrder . forEach ( ( item , i ) => {
220
+ for ( const [ i , item ] of attributeOrder . entries ( ) ) {
217
221
if ( Array . isArray ( item ) ) {
218
222
for ( const attr of item ) {
219
223
attributePosition [ attr ] = i
220
224
}
221
225
} else attributePosition [ item ] = i
222
- } )
226
+ }
223
227
224
228
/**
225
229
* @param {VAttribute | VDirective } node
@@ -319,8 +323,7 @@ function create(context) {
319
323
} )
320
324
321
325
const results = [ ]
322
- for ( let index = 0 ; index < attributes . length ; index ++ ) {
323
- const attr = attributes [ index ]
326
+ for ( const [ index , attr ] of attributes . entries ( ) ) {
324
327
const position = getPositionFromAttrIndex ( index )
325
328
if ( position == null ) {
326
329
// The omitted order is skipped.
0 commit comments