File tree Expand file tree Collapse file tree 1 file changed +5
-4
lines changed
Expand file tree Collapse file tree 1 file changed +5
-4
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ class Gist extends React.PureComponent {
1919 }
2020
2121 _updateIframeContent ( ) {
22- const { id } = this . props ;
22+ const { id, file } = this . props ;
2323
2424 const iframe = this . iframeNode ;
2525
@@ -30,7 +30,8 @@ class Gist extends React.PureComponent {
3030 const gistLink = this . _defineUrl ( )
3131 const gistScript = `<script type="text/javascript" src="${ gistLink } "></script>` ;
3232 const styles = '<style>*{font-size:12px;}</style>' ;
33- const resizeScript = `onload="parent.document.getElementById('gist-${ id } ').style.height=document.body.scrollHeight + 'px'"` ;
33+ const elementId = file ? `gist-${ id } -${ file } ` : `gist-${ id } ` ;
34+ const resizeScript = `onload="parent.document.getElementById('${ elementId } ').style.height=document.body.scrollHeight + 'px'"` ;
3435 const iframeHtml = `<html><head><base target="_parent">${ styles } </head><body ${ resizeScript } >${ gistScript } </body></html>` ;
3536
3637 doc . open ( ) ;
@@ -39,14 +40,14 @@ class Gist extends React.PureComponent {
3940 }
4041
4142 render ( ) {
42- const { id } = this . props ;
43+ const { id, file } = this . props ;
4344
4445 return (
4546 < iframe
4647 ref = { ( n ) => { this . iframeNode = n ; } }
4748 width = "100%"
4849 frameBorder = { 0 }
49- id = { `gist-${ id } ` }
50+ id = { file ? `gist- ${ id } - ${ file } ` : `gist-${ id } ` }
5051 />
5152 ) ;
5253 }
You can’t perform that action at this time.
0 commit comments