* Goal of the optimizer: walk the generated template AST tree * and detect sub-trees that are purely static, i.e. parts of * the DOM that never needs to change. * * Once we detect these sub-trees, we can: * * 1. Hoist them into constants, so that we no longer need to
(root, options)
| 14299 | * 根据node.static或者 node.once 标记staticRoot的状态 |
| 14300 | */ |
| 14301 | function optimize(root, options) { |
| 14302 | if (!root) { |
| 14303 | return |
| 14304 | } |
| 14305 | //匹配type,tag,attrsList,attrsMap,plain,parent,children,attrs + staticKeys 字符串 |
| 14306 | isStaticKey = genStaticKeysCached(options.staticKeys || ''); |
| 14307 | //保留标签 判断是不是真的是 html 原有的标签 或者svg标签 |
| 14308 | isPlatformReservedTag = options.isReservedTag || no; |
| 14309 | // first pass: mark all non-static nodes. |
| 14310 | ////第一遍:标记所有非静态节点。 |
| 14311 | //循环递归虚拟node,标记不是静态节点 |
| 14312 | markStatic$1(root); |
| 14313 | // second pass: mark static roots. |
| 14314 | //第二步:标记静态根。 |
| 14315 | markStaticRoots(root, false); |
| 14316 | } |
| 14317 | |
| 14318 | //匹配type,tag,attrsList,attrsMap,plain,parent,children,attrs +key 字符串 |
| 14319 | function genStaticKeys$1(keys) { |
no test coverage detected