-
feat: added an option to extend the allowed attribute type on all tags all at once (#330)
Added a new functionality that allows users to define a type that all attributes on all tags will accept.
class Box<T> { constructor(public v: T) {} toString() { return String(this.v); } } declare global { namespace JSXTE { interface AttributeAcceptedTypes { ALL: Box<any>; } } } // thanks to the interface declared above, the following will not raise errors: const div = <div class={new Box(123)}></div>; // ok
-
feat: improved the typing for the Dom renderer to better acommodate jsdom, happydom or similar libs (#312)
Improved the typing for the DomRenderer to better accommodate for fake Dom libraries like
jsdom
,happy-dom
, etc. -
feat: add dom render methods to component api and allow for option overrides (#311)
Added a
renderToDom
andrenderToDomAsync
options to the Component API.Added the option to override the renderer options when calling any render method via the Component API.
-
fix: prevent adding unintended whitespaces to the generated html (#310)
Fixed an issue where the generated html with
compact
option set as false (which is the default) would add unintended whitespaces between text elements separated by open or closing tags.Also replaced the
compact
option withpretty
, as from now on the default is to produce non formatted html.
-
feat: rewritten the renderer (#280)
Rewritten the renderer into a more generic solution, previous version had 4 different copies of render functions (html sync /async renderers and json sync/async renderers) and a lot of duplicated code. This new version introduces a generic
JsxteRenderer
class which performs most of the work while unaware of the final output format, and is capable of both synchornous and asynchronous work. This separation allows for better code reuse and smaller library size, and makes it easier to introduce new changes in the future. -
feat: removed the
renderToStringTemplateTag
render function (#279)Removed the string template renderer.
-
fix: missing meta properties and button disabled prop type (#272)
Added the missing
<meta>
tag properties to the prop type definitions (property
andmedia
).Fixed the typing on the
<button>
disabled property.
-
feat: removed fragments from the render error's component traces (#258)
In the previous version a new feature was added that added component traces to the rendering errors. As a result you would see error messages that looked like this:
JsxteRendererError: The below error has occurred in: <html> <body> <div> <> <span> Rendering has failed due to an error...
These messages have been updated to omit fragments from these traces, i.e.
<>
tags will no longer appear in the error message traces. -
feat: added types for the search tag (#256)
Added a type definition for the newly standardized
<search>
tag.
-
fix: incorrect function name exported from jsx-dev-runtime (#257)
The
jsx-dev-runtime
export is supposed to provide a named exported function under the namejsxDEV
, that however was not the case, as it was only exporting functions that were named identically to those fromjsx-runtime
. -
fix: meta's name and link's rel attribute types prevented valid values (#255)
Type for the
<meta>
'sname
attribute was preventing valid values from being used, same for the<link>
'srel
attribute. These attributes will now allow any string to be used.
-
feat: added component traces to errors (#236)
Added traces to errors thrown by the renderer to allow easier debugging. This is achieved by catching any errors during rendering and when that happens, throwing custom errors instead. Original errors can still be accessed via the
.cause
property.If an error occurs in a component called
MyComponent
you might see an error like this:JsxteRendererError: The below error has occurred in: <App> <html> <body> <Layout> <div> <MyComponent> Rendering has failed due to an error: <Actual error message>
try { const html = renderToHtml(<App />); } catch (error) { error; // -> JsxteRendererError error.cause; // -> original error }
-
feat: added toHtmlTag symbol (#235)
Added a special symbol that allows to determine how an object should be stringified when used as a child of a JSX element.
class User { constructor( public id: string, public username: string, public email: string, ) {} [Symbol.toHtmlTag]() { return `User: ${this.username}`; } } const user = new User("001", "Johny", "[email protected]"); renderToHtml(<div>{user}</div>);
The above will produce this result:
<div>User: Johny</div>
-
feat: added jsx-dev-runtime to the exported paths (#234)
Added a new export under
jsxte/jsx-dev-runtime
, atm it exports the exact same functions as thejsxte/jsx-runtime
. This should prevent build errors when the "jsx" build option is set tojsx-reactdev
. This change specifically targets Bun, which always assumes this settings unless NODE_ENV is set toproduction
.
-
fix: add "canonical" as allowed attribute for link-rel (#231)
-
feat: Add view-transition as allowed name for meta-tag. (#225)
Updated types for the
<meta>
tag to allow for theview-transition
as name attribute value. -
feat: allow null, undefined, booleans, string and numbers as jsx elements (#221)
It is now possible to return other things from function components than elements created via
createElement
or JSX syntax. Anything that is not an object, string or number will be treated as if<></>
was returned, returned strings and numbers will be treated as<>{value}</>
, objects are expected to be elements created viacreateElement
or JSX syntax (no change here).This means that the following components are now possible:
function MyComponent() { return !!condition && <div>...</div>; } function MyComponent() { return "Hello"; } function MyComponent() { return 2023; } // ok renderToHtml( <div> <MyComponent /> </div>, );
-
fix: types for specific elements were missing (#218)
Types for many elements were missing, this was because types for them were defined as a namespace interfaces in standalone files that were never imported and therefore TypeScript would never load them.
-
fix: self closing tags (#203)
Fixed the issue with the html renderer always producing a separate closing tag, even in cases where the tag could be self closing.
-
fix: removed prop types exports (#193)
Exports of all tags prop types were removed, instead those are available via the
JSXTE
global namespace.
-
fix: as attribute typing for link tag (#193)
Added missing property from the
<link>
tag's prop type, theas
attribute.
-
fix: added
number
as a possible type for input attributesstep
andvalue
(#187)Added
number
as a possible type for input attributesstep
andvalue
. -
fix: added a few event handler property types that were missing (#186)
Typing for the JSX html elements were missing some of the event handlers attributes (
onpointer
events,onfocusin
etc.). This is fixed now.
-
feat: added a json renderer (#185)
Added a new renderer that can generate a JSON structure instead of html. Api for it looks similar to
renderToHtml
with the only difference being it does not accept any indentation option. -
feat: optimized the code (for..let loops over for..of, faster string join algo, etc.) (#184)
Added code optimizations:
- Instead of
for..of
loops that rely on iterators used the good ol'for..let i = 0;
loops which are much faster - Replaced all usages of
String.join()
with a much faster custom implementation - Reduced the amount of needless object instantiations, (there were some places where a new object or array was created for convenience reasons, but was not really necessary) - this should slightly reduce the required GC time for cases where a lot of JSX is being processed.
- JSX Elements props and children are made immutable up-front via
Object.freeze
- Instead of
-
feat: improvements to the
renderToStringTemplateTag
(#183)Multiple improvements to the render function for string template tags:
- New
<Interpolate>
and<InterpolateTag>
components. Contents of those will be interpolated into the string template as is for Interpolate, and as a rendered tag for InterpolateTag (see JSDoc comments on those for more details. - Falsy values passed to the attributes will prevent those attributes from being added at all, while truthy values will cause those attributes to be added with their names as values.
- Caching mechanism to allow for the same input to provide the exact same TemplateStringArray reference to the tag on every call.
- New
-
chore: added a sideEffect property to package.json (#181)
Added a sideEffect property to package.json to allow for tree-shaking.
-
feat: added helper methods to the context: Provider and Consumer (#161)
Added two helper methods to the Context object. A
Provider
and aConsumer
are JSXTE Components that provide similar functionality to the React's Context.const myCtx = defineContext<{ foo: string }>; const App = () => { return ( <myCtx.Provider value={{ foo: "hello" }}> <myCtx.Consumer render={(cv) => <span>{cv.foo}</span>} /> </myCtx.Provider> ); };
-
feat: ContextMap replaced with ComponentApi (#160)
Replaced the
ContextMap
argument that was available to to all components with a newComponentApi
. Contexts can still be accessed via the new API, via theComponentApi.ctx
property. Additionally the new api provides arender
method, which can be used similarly to therenderToHtml
, but the context's data will get forwarded to the rendered components.