File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1200,12 +1200,20 @@ export function base_parse(data: string, options = {} as Partial<Options>) {
12001200 '' ;
12011201 if ( kElementsClosedByClosingExcept [ openTag ] ) {
12021202 const closingTag = tagName . toLowerCase ( ) ;
1203- if ( ! kElementsClosedByClosingExcept [ openTag ] [ closingTag ] ) {
1204- // Update range end for closed tag
1205- ( < [ number , number ] > currentParent . range ) [ 1 ] = createRange ( - 1 , Math . max ( lastTextPos , tagEndPos ) ) [ 1 ] ;
1206- stack . pop ( ) ;
1207- currentParent = arr_back ( stack ) ;
1208- continue ;
1203+ if ( stack . length > 1 ) {
1204+ const possibleContainer = stack [ stack . length - 2 ] ;
1205+ if (
1206+ possibleContainer &&
1207+ possibleContainer . rawTagName &&
1208+ possibleContainer . rawTagName . toLowerCase ( ) === closingTag &&
1209+ ! kElementsClosedByClosingExcept [ openTag ] [ closingTag ]
1210+ ) {
1211+ // Update range end for closed tag
1212+ ( < [ number , number ] > currentParent . range ) [ 1 ] = createRange ( - 1 , Math . max ( lastTextPos , tagEndPos ) ) [ 1 ] ;
1213+ stack . pop ( ) ;
1214+ currentParent = arr_back ( stack ) ;
1215+ continue ;
1216+ }
12091217 }
12101218 }
12111219 // Use aggressive strategy to handle unmatching markups.
You can’t perform that action at this time.
0 commit comments