(
children,
maybeComponent
)
| 15169 | // 2:需要完全标准化 |
| 15170 | //如果children.length==0 就返回0,如果如果有for属性存在或者tag等于template或者是slot 则问真就返回1,如果是组件则返回2 |
| 15171 | function getNormalizationType( |
| 15172 | children, |
| 15173 | maybeComponent |
| 15174 | ) { |
| 15175 | var res = 0; |
| 15176 | for (var i = 0; i < children.length; i++) { //循环子节点 |
| 15177 | var el = children[i]; |
| 15178 | if (el.type !== 1) { //如果是真是dom则跳过循环 |
| 15179 | continue |
| 15180 | } |
| 15181 | //如果有for属性存在或者tag等于template或者是slot 则问真 |
| 15182 | if (needsNormalization(el) || |
| 15183 | (el.ifConditions && el.ifConditions.some(function (c) { //判断数组中是否存在满足条件的项,只要有一项满足条件,就会返回true。 |
| 15184 | return needsNormalization(c.block); |
| 15185 | }))) { |
| 15186 | res = 2; |
| 15187 | break |
| 15188 | } |
| 15189 | if (maybeComponent(el) || //判断是否是组件 |
| 15190 | (el.ifConditions && el.ifConditions.some(function (c) {//判断数组中是否存在满足条件的项,只要有一项满足条件,就会返回true。 |
| 15191 | return maybeComponent(c.block); |
| 15192 | }))) { |
| 15193 | res = 1; |
| 15194 | } |
| 15195 | } |
| 15196 | return res |
| 15197 | } |
| 15198 | |
| 15199 | //如果for属性存在或者tag等于template或者是slot 则问真 |
| 15200 | function needsNormalization(el) { |
no test coverage detected