You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 6cbe361
Browse filesBrowse the repository at this point in the historyBrowse files
fix(jsx): escape element and object attribute values (#5512)
* fix(jsx): escape element and object attribute values
Render JSX nodes and other objects as escaped attribute text, including
promised values and asynchronous toString results. Mark precompiled JSX
templates so their child-content escaping is not trusted inside attributes.
Keep raw() and html values explicitly trusted, and prevent callbacks from
escaped nodes from propagating into the outer stream. Cover both runtimes
and the Deno precompile transform.
Co-authored-by: Taku Amano <[email protected]>
* perf(jsx): use a set for boolean attribute lookup
Use Set.has for boolean attribute membership without changing the accepted
attribute names or their rendering.
* fix(jsx): serialize boolean attributes in precompiled JSX
Omit false boolean attributes and emit an empty value for true ones in
jsxAttr, matching JSXNode. Preserve true/false text for non-boolean names.
* feat(jsx): support declarative Shadow DOM boolean attributes
Recognize shadowrootclonable, shadowrootdelegatesfocus, and
shadowrootserializable as boolean attributes. Cover true and false values
in both attribute serializers.
Co-authored-by: Taku Amano <[email protected]>
* fix(jsx): omit null style attributes
Skip null style values before traversing the style object in both
JSXNode and jsxAttr. Cover null and undefined omission.
Co-authored-by: Taku Amano <[email protected]>
* fix(jsx): validate function attributes in precompiled JSX
Skip on-prefixed event handlers and ref callbacks in jsxAttr. Reject
functions on other attributes with the same rule as JSXNode, including
when the Deno precompile transform calls jsxAttr.
Co-authored-by: Taku Amano <[email protected]>
* refactor(jsx): share attribute serialization between JSXNode and jsxAttr
Use attributeToBuffer for both render paths so attribute handling cannot
drift between them. Keep the explicit string conversion required by the
buffer type.
Handle dangerouslySetInnerHTML separately when the value is an object
with __html; other values follow the normal attribute serializer.
* perf(jsx): add a string fast path to jsxAttr
Escape string values directly in jsxAttr instead of going through
attributeToBuffer. Strings are the common case in precompiled JSX, and
the shared serializer made them about 50% slower on Deno.
* fix(jsx): resolve function form actions in precompiled JSX
Functions passed to action and formaction threw in jsxAttr, while the
form, input and button intrinsic elements accept them when rendered
through JSXNode. Resolve them in the same way: use the permalink when
one is attached and omit the attribute otherwise.
* fix(jsx): escape async render results used as attribute values
An asynchronous JSXNode.toString() resolves to an HtmlEscapedString that
contains markup. It was trusted as an attribute value, while the string
from a synchronous render was escaped. Mark it in the same way as a
precompiled template so that both are escaped.
* refactor(jsx): rename JSX_TEMPLATE to RENDERED_JSX
The mark is no longer specific to precompiled templates; asynchronous
JSXNode render results carry it too. Rename the symbol and its helper
to match. No behavior change.
---------
Co-authored-by: Neil <[email protected]>
0 commit comments