Skip to content

Commit

Permalink
fix: REPL style insert in FireFox (#1163)
Browse files Browse the repository at this point in the history
* fix: REPL style insert in FireFox

* chore: Remove extraneous spacing
  • Loading branch information
rschristian authored Jul 3, 2024
1 parent d986799 commit 244841d
Showing 1 changed file with 17 additions and 10 deletions.
27 changes: 17 additions & 10 deletions src/components/controllers/repl/runner.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -112,16 +112,23 @@ export default class Runner extends Component {
onError: this.commitError
});
this.realm.globalThis.fetch = cachedFetch;
let doc = this.realm.globalThis.document;
let style = doc.createElement('style');
style.appendChild(
doc.createTextNode(`
html { font: 100%/1.3 system-ui, sans-serif; background: none; }
${this.props.css || ''}
`)
);
doc.head.appendChild(style);
createRoot(doc);

const insertStyles = () => {
const doc = this.realm.globalThis.document,
style = doc.createElement('style');
style.appendChild(
doc.createTextNode(`
html { font: 100%/1.3 system-ui, sans-serif; background: none; }
${this.props.css || ''}
`)
);
doc.head.appendChild(style);
createRoot(doc);
};

this.frame.current.contentDocument.readyState !== 'complete'
? this.frame.current.onload = insertStyles
: insertStyles();
}

async execute(transpiled, isFallback) {
Expand Down

0 comments on commit 244841d

Please sign in to comment.