mirror of
https://github.com/naturalcrit/homebrewery.git
synced 2025-12-27 09:22:44 +00:00
Fixed renderer crashing with malformed html on load
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
- Changed icon for the metadata
|
||||
- Made links useable in footer (thanks u/Dustfinger1 re:249)
|
||||
- Added print media queries to remove box shadow on print (thanks u/dmmagic re: 246)
|
||||
|
||||
- Fixed realtime renderer not functioning if loaded with malformed html on load (thanks u/RattiganIV re:247)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -33,6 +33,7 @@ const BrewRenderer = React.createClass({
|
||||
},
|
||||
height : 0,
|
||||
pageHeight : PAGE_HEIGHT,
|
||||
lastRender : <div></div>,
|
||||
|
||||
componentDidMount: function() {
|
||||
this.updateSize();
|
||||
@@ -43,7 +44,7 @@ const BrewRenderer = React.createClass({
|
||||
},
|
||||
|
||||
componentWillReceiveProps: function(nextProps) {
|
||||
if(this.refs.pages.firstChild) this.pageHeight = this.refs.pages.firstChild.clientHeight;
|
||||
if(this.refs.pages && this.refs.pages.firstChild) this.pageHeight = this.refs.pages.firstChild.clientHeight;
|
||||
|
||||
const pages = nextProps.text.split('\\page');
|
||||
this.setState({
|
||||
@@ -54,7 +55,7 @@ const BrewRenderer = React.createClass({
|
||||
|
||||
updateSize : function() {
|
||||
setTimeout(()=>{
|
||||
if(this.refs.pages.firstChild) this.pageHeight = this.refs.pages.firstChild.clientHeight;
|
||||
if(this.refs.pages && this.refs.pages.firstChild) this.pageHeight = this.refs.pages.firstChild.clientHeight;
|
||||
}, 1);
|
||||
|
||||
this.setState({
|
||||
@@ -117,10 +118,11 @@ const BrewRenderer = React.createClass({
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return _.map(this.state.pages, (page, index)=>{
|
||||
if(this.props.errors && this.props.errors.length) return this.lastRender;
|
||||
this.lastRender = _.map(this.state.pages, (page, index)=>{
|
||||
return this.renderPage(page, index);
|
||||
});
|
||||
return this.lastRender;
|
||||
},
|
||||
|
||||
render : function(){
|
||||
|
||||
@@ -47,7 +47,7 @@ const EditPage = React.createClass({
|
||||
isSaving : false,
|
||||
isPending : false,
|
||||
errors : null,
|
||||
htmlErrors : [],
|
||||
htmlErrors : Markdown.validate(this.props.brew.text),
|
||||
lastUpdated : this.props.brew.updatedAt
|
||||
};
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user