mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-11-29 15:12:58 +03:00
Fixed firefox iframe append issue
no issue Firefox doesn't allow adding content to iframe body without passing `srcDoc={`<!DOCTYPE html>` to the iframe, this allows iframe to load properly
This commit is contained in:
parent
e7973cf37a
commit
b50abb5ad2
@ -3,6 +3,18 @@ import {createPortal} from 'react-dom';
|
||||
|
||||
export default class Frame extends Component {
|
||||
componentDidMount() {
|
||||
this.node.addEventListener('load', this.handleLoad);
|
||||
}
|
||||
|
||||
handleLoad = () => {
|
||||
this.setupFrameBaseStyle();
|
||||
};
|
||||
|
||||
componentWillUnmout() {
|
||||
this.node.removeEventListener('load', this.handleLoad);
|
||||
}
|
||||
|
||||
setupFrameBaseStyle() {
|
||||
this.iframeHtml = this.node.contentDocument.documentElement;
|
||||
this.iframeHtml.style.fontSize = '62.5%';
|
||||
|
||||
@ -20,7 +32,7 @@ export default class Frame extends Component {
|
||||
render() {
|
||||
const {children, head, title = '', style = {}, ...rest} = this.props;
|
||||
return (
|
||||
<iframe {...rest} ref={node => (this.node = node)} title={title} style={style} frameBorder="0">
|
||||
<iframe srcDoc={`<!DOCTYPE html>`} {...rest} ref={node => (this.node = node)} title={title} style={style} frameBorder="0">
|
||||
{this.iframeHead && createPortal(head, this.iframeHead)}
|
||||
{this.iframeRoot && createPortal(children, this.iframeRoot)}
|
||||
</iframe>
|
Loading…
Reference in New Issue
Block a user