Saltar al contenido
TE139 · Parser · error

Elemento de texto crudo `<style>`/`<script>` sin cerrar

`<style>` y `<script>` son elementos de texto crudo: su contenido corre literal hasta el `</style>`/`</script>` correspondiente, sin markup anidado y sin interpolación `{expr}`. Llegar al final del archivo antes de ese cierre reporta TE139 en lugar del mensaje genérico "unclosed element" — normalmente una etiqueta de cierre olvidada, o una cadena con forma `</tag` dentro del contenido (por ejemplo, un literal de cadena JS) que cerró el bloque antes de tiempo.

Why this fires

<style> and <script> are raw text elements: once the parser sees the opening tag, everything up to the matching </style> or </script> is taken verbatim as the element's content — literal CSS or JavaScript text. No nested markup is recognized, no {expr} interpolation runs, and no entity is decoded. The only thing that can end the block is the exact closing tag.

TE139 fires when the file ends before that closing tag shows up. The two common causes:

  • The closing tag was simply forgotten.
  • A </style or </script-shaped sequence appears inside the content — most often a JavaScript string containing "</script>" — and the parser (correctly, per the raw-text rule) treated it as the close, then ran out of file looking for a second one.
fn page() -> Element {
    return <div>
        <style>
            .card { padding: 8px }
    </div>
    //  ^ error[TE139]: unclosed `<style>`: a raw text element's content runs
    //    until `</style>`, and none was found before the end of the file.
}

Fix it

1. Close the block

<style>
    .card { padding: 8px }
</style>

2. Escape a closing sequence that must appear inside JavaScript content

A JS string containing the literal text </script> closes the block early, exactly the way it does in HTML:

<script>
    console.log("</script>")   // closes the block here — TE139 on whatever follows
</script>

Split the sequence so the raw-text scanner doesn't recognize it:

<script>
    console.log("<\/script>")  // ok — no longer a literal `</script>` in the source text
</script>

See also

  • Ordinary elements report a different, generic message when unclosed (unclosed element with no code) — <style>/<script> get TE139 specifically because the raw-text rule (verbatim content, no nested markup) makes the fix different from a missing </div>.

Véase también

Buscar en Zolo

9 resultados

en