|
4 | 4 | * See LICENSE file in root directory for full license.
|
5 | 5 | */
|
6 | 6 | import assert from "assert"
|
7 |
| -import last from "lodash/last" |
8 |
| -import findLastIndex from "lodash/findLastIndex" |
9 | 7 | import type {
|
10 | 8 | ErrorCode,
|
11 | 9 | HasLocation,
|
@@ -52,8 +50,7 @@ import {
|
52 | 50 | getScriptParser,
|
53 | 51 | getParserLangFromSFC,
|
54 | 52 | } from "../common/parser-options"
|
55 |
| -import sortedIndexBy from "lodash/sortedIndexBy" |
56 |
| -import sortedLastIndexBy from "lodash/sortedLastIndexBy" |
| 53 | +import { sortedIndexBy, sortedLastIndexBy } from "../utils/utils" |
57 | 54 | import type {
|
58 | 55 | CustomTemplateTokenizer,
|
59 | 56 | CustomTemplateTokenizerConstructor,
|
@@ -160,7 +157,7 @@ function adjustAttributeName(name: string, namespace: Namespace): string {
|
160 | 157 | */
|
161 | 158 | function propagateEndLocation(node: VDocumentFragment | VElement): void {
|
162 | 159 | const lastChild =
|
163 |
| - (node.type === "VElement" ? node.endTag : null) || last(node.children) |
| 160 | + (node.type === "VElement" ? node.endTag : null) || node.children.at(-1) |
164 | 161 | if (lastChild != null) {
|
165 | 162 | node.range[1] = lastChild.range[1]
|
166 | 163 | node.loc.end = lastChild.loc.end
|
@@ -236,7 +233,7 @@ export class Parser {
|
236 | 233 | * Get the current node.
|
237 | 234 | */
|
238 | 235 | private get currentNode(): VDocumentFragment | VElement {
|
239 |
| - return last(this.elementStack) || this.document |
| 236 | + return this.elementStack.at(-1) || this.document |
240 | 237 | }
|
241 | 238 |
|
242 | 239 | /**
|
@@ -701,8 +698,7 @@ export class Parser {
|
701 | 698 | protected EndTag(token: EndTag): void {
|
702 | 699 | debug("[html] EndTag %j", token)
|
703 | 700 |
|
704 |
| - const i = findLastIndex( |
705 |
| - this.elementStack, |
| 701 | + const i = this.elementStack.findLastIndex( |
706 | 702 | (el) => el.name.toLowerCase() === token.name,
|
707 | 703 | )
|
708 | 704 | if (i === -1) {
|
|
0 commit comments