(context, ancestors)
| 82 | }; |
| 83 | |
| 84 | const parseElement = (context, ancestors) => { |
| 85 | // Implement |
| 86 | // 1. 解析tag |
| 87 | const element: any = parseTag(context, TagType.START); |
| 88 | ancestors.push(element); |
| 89 | // 如果有子节点则内部递归处理 |
| 90 | element.children = parseChildren(context, ancestors); |
| 91 | ancestors.pop(); |
| 92 | // if (context.source) { |
| 93 | if (startsWithEndTagOpen(context.source, element.tag)) { |
| 94 | parseTag(context, TagType.END); |
| 95 | } else { |
| 96 | throw new Error(`缺少结束标签:${element.tag}`); |
| 97 | } |
| 98 | // } |
| 99 | return element; |
| 100 | }; |
| 101 | |
| 102 | const startsWithEndTagOpen = (source, tag) => { |
| 103 | return ( |
no test coverage detected