Skip to content
This repository has been archived by the owner on Jun 4, 2024. It is now read-only.

Commit

Permalink
Check whether exports is an empty object.
Browse files Browse the repository at this point in the history
See discussion and comment here: highlightjs/highlight.js#1245 (comment)
  • Loading branch information
Shammamah Hossain committed Dec 13, 2019
1 parent 4d2e5b3 commit a5ad414
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
2 changes: 2 additions & 0 deletions src/dash-table/LazyLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ export default class LazyLoader {
}

public static get hljs() {
// @ts-ignore
return import(/* webpackChunkName: "highlight", webpackMode: "$${{mode}}" */ '../../third-party/highlight.pack');
}

public static get hljsStyles() {
// @ts-ignore
return import(/* webpackChunkName: "highlight-styles", webpackMode: "$${{mode}}" */ '../../third-party/styles/github.css');
}

Expand Down
10 changes: 4 additions & 6 deletions src/dash-table/components/CellMarkdown/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ interface IState {
hljsStylesLoaded: any;
}


let hljsResolve: () => any;
let hljsStylesResolve: () => any;

Expand All @@ -32,13 +31,12 @@ let hljsStylesLoaded: Promise<boolean> | true = new Promise<boolean>(resolve =>
});

let hljs: any;
let hljsStyles: any
let hljsStyles: any;

export default class CellMarkdown extends PureComponent<IProps, IState> {

private static readonly md: Remarkable = new Remarkable({
highlight: function(str: string, lang: string) {

highlight: (str: string, lang: string) => {
if (hljs && hljsStyles) {
if (lang && hljs.getLanguage(lang)) {
try {
Expand Down Expand Up @@ -73,11 +71,11 @@ export default class CellMarkdown extends PureComponent<IProps, IState> {

constructor(props: IProps) {
super(props);
this.state = { hljsLoaded, hljsStylesLoaded }
this.state = { hljsLoaded, hljsStylesLoaded };

// if doesn't equal true, assume it's a promise
if (hljsLoaded !== true) {
Promise.all([hljsLoaded, hljsStylesLoaded]).then(() => { this.setState({ hljsLoaded: true }) });
Promise.all([hljsLoaded, hljsStylesLoaded]).then(() => { this.setState({ hljsLoaded: true }); });
}
}

Expand Down
Loading

0 comments on commit a5ad414

Please sign in to comment.