Skip to content

[WIP] display the script error caused by external library #579

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Mar 2, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 7 additions & 4 deletions client/modules/IDE/components/PreviewFrame.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ function getAllScriptOffsets(htmlFile) {
} else {
endFilenameInd = htmlFile.indexOf('.js', ind + startTag.length + 3);
filename = htmlFile.substring(ind + startTag.length, endFilenameInd);
// the length of hijackConsoleErrorsScript is 31 lines
lineOffset = htmlFile.substring(0, ind).split('\n').length + 31;
// the length of hijackConsoleErrorsScript is 33 lines
lineOffset = htmlFile.substring(0, ind).split('\n').length + 33;
offs.push([lineOffset, filename]);
lastInd = ind + 1;
}
Expand Down Expand Up @@ -65,8 +65,10 @@ function hijackConsoleErrorsScript(offs) {
var string = msg.toLowerCase();
var substring = "script error";
var data = {};
if (string.indexOf(substring) !== -1){
data = 'Script Error: See Browser Console for Detail';
if (url.match(${EXTERNAL_LINK_REGEX}) !== null && error.stack){
var errorNum = error.stack.split('about:srcdoc:')[1].split(':')[0];
var fileInfo = getScriptOff(errorNum);
data = msg + ' (' + fileInfo[1] + ': line ' + fileInfo[0] + ')';
} else {
var fileInfo = getScriptOff(lineNumber);
data = msg + ' (' + fileInfo[1] + ': line ' + fileInfo[0] + ')';
Expand Down Expand Up @@ -340,6 +342,7 @@ class PreviewFrame extends React.Component {
}
}
} else if (!(script.getAttribute('src') && script.getAttribute('src').match(EXTERNAL_LINK_REGEX)) !== null) {
script.setAttribute('crossorigin', '');
script.innerHTML = this.resolveJSLinksInString(script.innerHTML, files); // eslint-disable-line
}
});
Expand Down