(node: ElementNode)
| 236 | // probably only need to check for most common case |
| 237 | // i.e. non-phrasing-content tags inside `<p>` |
| 238 | function walk(node: ElementNode): boolean { |
| 239 | const isOptionTag = node.tag === 'option' && node.ns === Namespaces.HTML |
| 240 | for (let i = 0; i < node.props.length; i++) { |
| 241 | const p = node.props[i] |
| 242 | // bail on non-attr bindings |
| 243 | if ( |
| 244 | p.type === NodeTypes.ATTRIBUTE && |
| 245 | !isStringifiableAttr(p.name, node.ns) |
| 246 | ) { |
| 247 | return bail() |
| 248 | } |
| 249 | if (p.type === NodeTypes.DIRECTIVE && p.name === 'bind') { |
| 250 | // bail on non-attr bindings |
| 251 | if ( |
| 252 | p.arg && |
| 253 | (p.arg.type === NodeTypes.COMPOUND_EXPRESSION || |
| 254 | (p.arg.isStatic && !isStringifiableAttr(p.arg.content, node.ns))) |
| 255 | ) { |
| 256 | return bail() |
| 257 | } |
| 258 | if ( |
| 259 | p.exp && |
| 260 | (p.exp.type === NodeTypes.COMPOUND_EXPRESSION || |
| 261 | p.exp.constType < ConstantTypes.CAN_STRINGIFY) |
| 262 | ) { |
| 263 | return bail() |
| 264 | } |
| 265 | // <option :value="1"> cannot be safely stringified |
| 266 | if ( |
| 267 | isOptionTag && |
| 268 | isStaticArgOf(p.arg, 'value') && |
| 269 | p.exp && |
| 270 | !p.exp.isStatic |
| 271 | ) { |
| 272 | return bail() |
| 273 | } |
| 274 | } |
| 275 | } |
| 276 | for (let i = 0; i < node.children.length; i++) { |
| 277 | nc++ |
| 278 | const child = node.children[i] |
| 279 | if (child.type === NodeTypes.ELEMENT) { |
| 280 | if (child.props.length > 0) { |
| 281 | ec++ |
| 282 | } |
| 283 | walk(child) |
| 284 | if (bailed) { |
| 285 | return false |
| 286 | } |
| 287 | } |
| 288 | } |
| 289 | return true |
| 290 | } |
| 291 | |
| 292 | return walk(node) ? [nc, ec] : false |
| 293 | } |
no test coverage detected