MCPcopy Create free account
hub / github.com/MicrosoftEdge/WebView2Browser / closeTab

Function closeTab

wvbrowser_ui/controls_ui/tabs.js:99–134  ·  view source on GitHub ↗
(id)

Source from the content-addressed store, hash-verified

97}
98
99function closeTab(id) {
100 // If closing tab was active, switch tab or close window
101 if (id == activeTabId) {
102 if (tabs.size == 1) {
103 // Last tab is closing, shut window down
104 tabs.delete(id);
105 closeWindow();
106 return;
107 }
108
109 // Other tabs are open, switch to rightmost tab
110 var tabsEntries = Array.from(tabs.entries());
111 var lastEntry = tabsEntries.pop();
112 if (lastEntry[0] == id) {
113 lastEntry = tabsEntries.pop();
114 }
115 switchToTab(lastEntry[0], true);
116 }
117
118 // Remove tab element
119 var tabElement = document.getElementById(`tab-${id}`);
120 if (tabElement) {
121 tabElement.parentNode.removeChild(tabElement);
122 }
123 // Remove tab from map
124 tabs.delete(id);
125
126 var message = {
127 message: commands.MG_CLOSE_TAB,
128 args: {
129 tabId: id
130 }
131 };
132
133 window.chrome.webview.postMessage(message);
134}
135
136function updateFaviconURI(tabId, src) {
137 let tab = tabs.get(tabId);

Callers 2

messageHandlerFunction · 0.85
loadTabUIFunction · 0.85

Calls 2

closeWindowFunction · 0.85
switchToTabFunction · 0.85

Tested by

no test coverage detected