Home / Function/ styleBlockRanges() — tailwindcss Function Reference

styleBlockRanges() — tailwindcss Function Reference

Architecture documentation for the styleBlockRanges() function in is-safe-migration.ts from the tailwindcss codebase.

Entity Profile

Relationship Graph

Source Code

packages/@tailwindcss-upgrade/src/codemods/template/is-safe-migration.ts lines 194–215

const styleBlockRanges = new DefaultMap((source: string) => {
  let ranges: number[] = []
  let offset = 0

  while (true) {
    let startTag = source.indexOf('<style', offset)
    if (startTag === -1) return ranges

    offset = startTag + 1

    // Ensure the style looks like:
    // - `<style>`   (closed)
    // - `<style …>` (with attributes)
    if (!source[startTag + 6].match(/[>\s]/)) continue

    let endTag = source.indexOf('</style>', offset)
    if (endTag === -1) return ranges
    offset = endTag + 1

    ranges.push(startTag, endTag)
  }
})

Subdomains

Analyze Your Own Codebase

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

Try Supermodel Free