Home / Function/ traverseHtml() — vite Function Reference

traverseHtml() — vite Function Reference

Architecture documentation for the traverseHtml() function in html.ts from the vite codebase.

Entity Profile

Dependency Diagram

graph TD
  5800888e_ad6f_73a4_812a_c831c6a9eebf["traverseHtml()"]
  f8fe0737_718a_5509_b722_473f207d5906["html.ts"]
  5800888e_ad6f_73a4_812a_c831c6a9eebf -->|defined in| f8fe0737_718a_5509_b722_473f207d5906
  39f26be8_b1d9_a756_3043_474687a6bbb7["buildHtmlPlugin()"]
  39f26be8_b1d9_a756_3043_474687a6bbb7 -->|calls| 5800888e_ad6f_73a4_812a_c831c6a9eebf
  7514180d_f3bd_4f07_5c4e_5911c2a70a4c["injectNonceAttributeTagHook()"]
  7514180d_f3bd_4f07_5c4e_5911c2a70a4c -->|calls| 5800888e_ad6f_73a4_812a_c831c6a9eebf
  c7929a5b_9791_180a_9c0b_4f479fb4cf3f["devHtmlHook()"]
  c7929a5b_9791_180a_9c0b_4f479fb4cf3f -->|calls| 5800888e_ad6f_73a4_812a_c831c6a9eebf
  6f95d645_04ef_21fe_68b7_4c732e603766["handleParseError()"]
  5800888e_ad6f_73a4_812a_c831c6a9eebf -->|calls| 6f95d645_04ef_21fe_68b7_4c732e603766
  2a2bf9ad_8f89_870c_04d9_14a70860c2f2["traverseNodes()"]
  5800888e_ad6f_73a4_812a_c831c6a9eebf -->|calls| 2a2bf9ad_8f89_870c_04d9_14a70860c2f2
  style 5800888e_ad6f_73a4_812a_c831c6a9eebf fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/vite/src/node/plugins/html.ts lines 202–223

export async function traverseHtml(
  html: string,
  filePath: string,
  warn: Logger['warn'],
  visitor: (node: DefaultTreeAdapterMap['node']) => void,
): Promise<void> {
  // lazy load compiler
  const { parse } = await import('parse5')
  const warnings: ParseWarnings = {}
  const ast = parse(html, {
    scriptingEnabled: false, // parse inside <noscript>
    sourceCodeLocationInfo: true,
    onParseError: (e: ParserError) => {
      handleParseError(e, html, filePath, warnings)
    },
  })
  traverseNodes(ast, visitor)

  for (const message of Object.values(warnings)) {
    warn(colors.yellow(`\n${message}`))
  }
}

Domain

Subdomains

Frequently Asked Questions

What does traverseHtml() do?
traverseHtml() is a function in the vite codebase, defined in packages/vite/src/node/plugins/html.ts.
Where is traverseHtml() defined?
traverseHtml() is defined in packages/vite/src/node/plugins/html.ts at line 202.
What does traverseHtml() call?
traverseHtml() calls 2 function(s): handleParseError, traverseNodes.
What calls traverseHtml()?
traverseHtml() is called by 3 function(s): buildHtmlPlugin, devHtmlHook, injectNonceAttributeTagHook.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free