MCPcopy
hub / github.com/vitejs/vite / text

Method text

packages/vite/src/client/overlay.ts:264–294  ·  view source on GitHub ↗
(selector: string, text: string, linkFiles = false)

Source from the content-addressed store, hash-verified

262 }
263
264 text(selector: string, text: string, linkFiles = false): void {
265 const el = this.root.querySelector(selector)!
266 if (!linkFiles) {
267 el.textContent = text
268 } else {
269 let curIndex = 0
270 let match: RegExpExecArray | null
271 fileRE.lastIndex = 0
272 while ((match = fileRE.exec(text))) {
273 const { 0: file, index } = match
274 const frag = text.slice(curIndex, index)
275 el.appendChild(document.createTextNode(frag))
276 const link = document.createElement('a')
277 link.textContent = file
278 link.className = 'file-link'
279 link.onclick = () => {
280 fetch(
281 new URL(
282 `${base}__open-in-editor?file=${encodeURIComponent(file)}`,
283 import.meta.url,
284 ),
285 )
286 }
287 el.appendChild(link)
288 curIndex += frag.length + file.length
289 }
290 if (curIndex < text.length) {
291 el.appendChild(document.createTextNode(text.slice(curIndex)))
292 }
293 }
294 }
295 close(): void {
296 this.parentNode?.removeChild(this)
297 document.removeEventListener('keydown', this.closeOnEsc)

Callers 15

constructorMethod · 0.95
initFunction · 0.80
handleMsgFunction · 0.80
vitestSetup.tsFile · 0.80
getDepJsFunction · 0.80
ssr-html.spec.tsFile · 0.80
testClientReloadFunction · 0.80
onConsoleFunction · 0.80

Calls

no outgoing calls

Tested by 4

getDepJsFunction · 0.64
testClientReloadFunction · 0.64
onConsoleFunction · 0.64
onConsoleFunction · 0.64