1
0
mirror of https://github.com/chinchang/web-maker.git synced 2025-07-17 03:51:13 +02:00

add check on externalLibs before using

This commit is contained in:
Kushagra Gour
2018-06-22 20:35:18 +05:30
parent 0eec8bec91
commit f7c926e68a
2 changed files with 20 additions and 13 deletions

View File

@@ -513,6 +513,9 @@ export default class App extends Component {
updateExternalLibCount() { updateExternalLibCount() {
// Calculate no. of external libs // Calculate no. of external libs
var noOfExternalLibs = 0; var noOfExternalLibs = 0;
if (!this.state.currentItem.externalLibs) {
return;
}
noOfExternalLibs += this.state.currentItem.externalLibs.js noOfExternalLibs += this.state.currentItem.externalLibs.js
.split('\n') .split('\n')
.filter(lib => !!lib).length; .filter(lib => !!lib).length;

View File

@@ -307,12 +307,15 @@ export function getCompleteHtml(html, css, js, item, isForExport) {
if (!item) { if (!item) {
return ''; return '';
} }
var externalJs = item.externalLibs.js var externalJs = '',
externalCss = '';
if (item.externalLibs) {
externalJs = item.externalLibs.js
.split('\n') .split('\n')
.reduce(function(scripts, url) { .reduce(function(scripts, url) {
return scripts + (url ? '\n<script src="' + url + '"></script>' : ''); return scripts + (url ? '\n<script src="' + url + '"></script>' : '');
}, ''); }, '');
var externalCss = item.externalLibs.css externalCss = item.externalLibs.css
.split('\n') .split('\n')
.reduce(function(links, url) { .reduce(function(links, url) {
return ( return (
@@ -320,6 +323,7 @@ export function getCompleteHtml(html, css, js, item, isForExport) {
(url ? '\n<link rel="stylesheet" href="' + url + '"></link>' : '') (url ? '\n<link rel="stylesheet" href="' + url + '"></link>' : '')
); );
}, ''); }, '');
}
var contents = var contents =
'<!DOCTYPE html>\n' + '<!DOCTYPE html>\n' +
'<html>\n<head>\n' + '<html>\n<head>\n' +