mirror of
https://github.com/go-gitea/gitea.git
synced 2026-08-04 17:47:35 +00:00
fix: remove the pull merge box from UI when the refreshed page doesn't contain it (#38742)
On the PR view page, the "merge box" is refreshed periodically. If the PR changes (e.g.: merged and the head branch has been deleted), then the merge box doesn't exist in the refresh response. For such case, the merge box should also be removed from the UI.
This commit is contained in:
@@ -267,10 +267,10 @@ export function isElemVisible(el: HTMLElement): boolean {
|
||||
|
||||
export function createElementFromHTML<T extends Element>(htmlString: string): T {
|
||||
htmlString = htmlString.trim();
|
||||
if (!htmlString.startsWith('<')) throw new Error(`Invalid HTML element string: ${htmlString}`);
|
||||
const isLetter = (code: number) => (code >= 65 && code <= 90) || (code >= 97 && code <= 122);
|
||||
const startsWithTag = (s: string, tag: string) => {
|
||||
return s.startsWith('<') &&
|
||||
s.substring(1, 1 + tag.length).toLowerCase() === tag.toLowerCase() &&
|
||||
return s.substring(1, 1 + tag.length).toLowerCase() === tag.toLowerCase() &&
|
||||
!isLetter(s[1 + tag.length].charCodeAt(0));
|
||||
};
|
||||
// There is no way to create some elements without a proper parent, jQuery's approach: https://github.com/jquery/jquery/blob/main/src/manipulation/wrapMap.js
|
||||
|
||||
Reference in New Issue
Block a user