Changelog
3.3.1 (March 16, 2024)
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
Changelog
3.3.0 (February 1, 2024)
Improved the typing for the DomRenderer to better accommodate for fake Dom libraries like jsdom
, happy-dom
, etc.
Added a renderToDom
and renderToDomAsync
options to the Component API.
Added the option to override the renderer options when calling any render method via the Component API.
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 with pretty
, as from now on the default is to produce non formatted html.
Changelog
3.2.0 (January 28, 2024)
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.
renderToStringTemplateTag
render function (#279)Removed the string template renderer.
Changelog
3.1.8 (December 5, 2023)
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.
Added a type definition for the newly standardized <search>
tag.
The jsx-dev-runtime
export is supposed to provide a named exported function under the name jsxDEV
, that however was not the case, as it was only exporting functions that were named identically to those from jsx-runtime
.
Type for the <meta>
's name
attribute was preventing valid values from being used, same for the <link>
's rel
attribute. These attributes will now allow any string to be used.
Changelog
3.1.7 (November 5, 2023)
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
}
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", "johny0169@gmail.com");
renderToHtml(<div>{user}</div>);
The above will produce this result:
<div>User: Johny</div>
Added a new export under jsxte/jsx-dev-runtime
, atm it exports the exact same functions as the jsxte/jsx-runtime
. This should prevent build errors when the "jsx" build option is set to jsx-reactdev
. This change specifically targets Bun, which always assumes this settings unless NODE_ENV is set to production
.