Skip to content

Commit

Permalink
Revert " * core: add htmlRender option to HtmlContent."
Browse files Browse the repository at this point in the history
This reverts commit fe4b618.
  • Loading branch information
catouse committed Nov 12, 2024
1 parent 60e7b57 commit a8d046d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 21 deletions.
22 changes: 6 additions & 16 deletions lib/core/src/react/components/html-content.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,35 +17,25 @@ import type {HtmlContentProps} from '../types';
export class HtmlContent extends Component<HtmlContentProps> {
protected _ref = createRef<HTMLDivElement>();

update() {
const element = this._ref.current;
if (!element) {
protected _runJS() {
if (!this.props.executeScript) {
return;
}
(this.props.htmlRender || HtmlContent.update)(element, this.props);
$(this._ref.current).runJS().zuiInit();
}

componentDidMount(): void {
this.update();
this._runJS();
}

componentDidUpdate(previousProps: Readonly<HtmlContentProps>): void {
if (this.props.html !== previousProps.html) {
this.update();
this._runJS();
}
}

render(props: HtmlContentProps) {
const {executeScript, html, ...others} = props;
return <HElement forwardRef={this._ref} {...others} />;
}

static update(element: HTMLElement, props: HtmlContentProps) {
const {executeScript, html} = props;
if (executeScript) {
$(element).html(html);
} else {
element.innerHTML = html;
}
return <HElement forwardRef={this._ref} dangerouslySetInnerHTML={{__html: html}} {...others} />;
}
}
5 changes: 0 additions & 5 deletions lib/core/src/react/types/html-content-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,4 @@ export interface HtmlContentProps extends HElementProps {
* Execute script.
*/
executeScript?: boolean,

/**
* Element inner html updater.
*/
htmlRender?: (element: HTMLElement, props: HtmlContentProps) => void,
}

0 comments on commit a8d046d

Please sign in to comment.