@@ -111,30 +111,31 @@ function getAttributeType(attribute) {
111111 if ( attribute . directive ) {
112112 if ( ! isVBind ( attribute ) ) {
113113 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
138139 }
139140 }
140141 propName =
@@ -144,16 +145,19 @@ function getAttributeType(attribute) {
144145 } else {
145146 propName = attribute . key . name
146147 }
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
157161 }
158162}
159163
@@ -213,13 +217,13 @@ function create(context) {
213217
214218 /** @type { { [key: string]: number } } */
215219 const attributePosition = { }
216- attributeOrder . forEach ( ( item , i ) => {
220+ for ( const [ i , item ] of attributeOrder . entries ( ) ) {
217221 if ( Array . isArray ( item ) ) {
218222 for ( const attr of item ) {
219223 attributePosition [ attr ] = i
220224 }
221225 } else attributePosition [ item ] = i
222- } )
226+ }
223227
224228 /**
225229 * @param {VAttribute | VDirective } node
@@ -319,8 +323,7 @@ function create(context) {
319323 } )
320324
321325 const results = [ ]
322- for ( let index = 0 ; index < attributes . length ; index ++ ) {
323- const attr = attributes [ index ]
326+ for ( const [ index , attr ] of attributes . entries ( ) ) {
324327 const position = getPositionFromAttrIndex ( index )
325328 if ( position == null ) {
326329 // The omitted order is skipped.
0 commit comments