Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 9 additions & 4 deletions test/test_site/testUtil/diffHtml.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,16 +21,21 @@ const endsWithUnclosedPath = (fragment) => {
/**
* Checks if the ending portion of the fragment is inside an html tag
* true: <tag src=".../
* <panel header="<a>link</a>" src=".../
* false: <text> src="..
* <div/>
* <panel header="<a>link</a>"> src="...
*/
const endsWithOpeningTag = (fragment) => {
let numUnmatchedClosingBracket = 0;
for (let i = fragment.length - 1; i >= 0; i -= 1) {
if (fragment[i] === '<') {
return true;
}
if (fragment[i] === '>') {
return false;
numUnmatchedClosingBracket += 1;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe more intuitive to +1 before -1, and check for 0 explicitly.

if > {
  +1
} else if < {
  if 0 {
    return true
  }
  -1
}

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated the commit

} else if (fragment[i] === '<') {
if (numUnmatchedClosingBracket === 0) {
return true;
}
numUnmatchedClosingBracket -= 1;
}
}
return false;
Expand Down