Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 677b4dd

Browse files
blastZtleunen
authored andcommitted
Fix mutiple files bug (#5)
1 parent 290428a commit 677b4dd

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

‎src/index.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff 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
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /