Skip to content

shouldUseCDATA

shouldUseCDATA(content, threshold?) → boolean · XML

Determine if content should be wrapped in a CDATA section (based on special character count). See Chapter 22.

  • content (required): the text content to evaluate

  • threshold (optional): number of special chars that triggers CDATA

utlx
shouldUseCDATA("<script>alert('hi')</script>")  // true
shouldUseCDATA("plain text")                     // false

Released under AGPL-3.0.