From edc34d98c9d60aed79eefca34c1b78a71ae090be Mon Sep 17 00:00:00 2001 From: Blast Z Date: Wed, 17 Jan 2018 15:55:40 +0800 Subject: [PATCH] Fix mutiple files bug --- src/index.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index b40c4dd..96180b0 100644 --- a/src/index.js +++ b/src/index.js @@ -19,7 +19,7 @@ class Gist extends React.PureComponent { } _updateIframeContent() { - const { id } = this.props; + const { id, file } = this.props; const iframe = this.iframeNode; @@ -30,7 +30,8 @@ class Gist extends React.PureComponent { const gistLink = this._defineUrl() const gistScript = ``; const styles = ''; - const resizeScript = `onload="parent.document.getElementById('gist-${id}').style.height=document.body.scrollHeight + 'px'"`; + const elementId = file ? `gist-${id}-${file}` : `gist-${id}`; + const resizeScript = `onload="parent.document.getElementById('${elementId}').style.height=document.body.scrollHeight + 'px'"`; const iframeHtml = `${styles}${gistScript}`; doc.open(); @@ -39,14 +40,14 @@ class Gist extends React.PureComponent { } render() { - const { id } = this.props; + const { id, file } = this.props; return (