diff --git a/lib/core/src/react/components/html-content.tsx b/lib/core/src/react/components/html-content.tsx
index 6e414dcb8f..db63285b0a 100644
--- a/lib/core/src/react/components/html-content.tsx
+++ b/lib/core/src/react/components/html-content.tsx
@@ -17,25 +17,35 @@ import type {HtmlContentProps} from '../types';
export class HtmlContent extends Component {
protected _ref = createRef();
- protected _runJS() {
- if (!this.props.executeScript) {
+ update() {
+ const element = this._ref.current;
+ if (!element) {
return;
}
- $(this._ref.current).runJS().zuiInit();
+ (this.props.htmlRender || HtmlContent.update)(element, this.props);
}
componentDidMount(): void {
- this._runJS();
+ this.update();
}
componentDidUpdate(previousProps: Readonly): void {
if (this.props.html !== previousProps.html) {
- this._runJS();
+ this.update();
}
}
render(props: HtmlContentProps) {
const {executeScript, html, ...others} = props;
- return ;
+ return ;
+ }
+
+ static update(element: HTMLElement, props: HtmlContentProps) {
+ const {executeScript, html} = props;
+ if (executeScript) {
+ $(element).html(html);
+ } else {
+ element.innerHTML = html;
+ }
}
}
diff --git a/lib/core/src/react/types/html-content-props.ts b/lib/core/src/react/types/html-content-props.ts
index c71e6e215a..5821e495ef 100644
--- a/lib/core/src/react/types/html-content-props.ts
+++ b/lib/core/src/react/types/html-content-props.ts
@@ -13,4 +13,9 @@ export interface HtmlContentProps extends HElementProps {
* Execute script.
*/
executeScript?: boolean,
+
+ /**
+ * Element inner html updater.
+ */
+ htmlRender?: (element: HTMLElement, props: HtmlContentProps) => void,
}