Skip to content

Commit

Permalink
Fixed 'ReferenceError: document is not defined' when running under Ph…
Browse files Browse the repository at this point in the history
…antomJS
  • Loading branch information
niemyjski committed May 4, 2016
1 parent 307e55a commit fb534b7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tracekit",
"main": "tracekit.js",
"version": "0.4.2",
"version": "0.4.3",
"homepage": "https://github.com/csnover/TraceKit",
"description": "Cross browser stack traces",
"moduleType": [
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tracekit",
"main": "./tracekit.js",
"version": "0.4.2",
"version": "0.4.3",
"homepage": "https://github.com/csnover/TraceKit",
"description": "Cross browser stack traces",
"repository": {
Expand Down
8 changes: 4 additions & 4 deletions tracekit.js
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
*/
var source = '';
var domain = '';
try { domain = document.domain; } catch (e) { }
try { domain = window.document.domain; } catch (e) { }
var match = /(.*)\:\/\/([^:\/]+)([:\d]*)\/{0,1}([\s\S]*)/.exec(url);
if (match && match[2] === domain) {
source = loadSource(url);
Expand Down Expand Up @@ -592,12 +592,12 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
* @memberof TraceKit.computeStackTrace
*/
function findSourceByFunctionBody(func) {
if (_isUndefined(document)) {
if (_isUndefined(window && window.document)) {
return;
}

var urls = [window.location.href],
scripts = document.getElementsByTagName('script'),
scripts = window.document.getElementsByTagName('script'),
body,
code = '' + func,
codeRE = /^function(?:\s+([\w$]+))?\s*\(([\w\s,]*)\)\s*\{\s*(\S[\s\S]*\S)\s*\}\s*$/,
Expand Down Expand Up @@ -882,7 +882,7 @@ TraceKit.computeStackTrace = (function computeStackTraceWrapper() {
lineRE2 = /^\s*Line (\d+) of inline#(\d+) script in ((?:file|https?|blob)\S+)(?:: in function (\S+))?\s*$/i,
lineRE3 = /^\s*Line (\d+) of function script\s*$/i,
stack = [],
scripts = document.getElementsByTagName('script'),
scripts = (window && window.document && window.document.getElementsByTagName('script')),
inlineScriptBlocks = [],
parts;

Expand Down

0 comments on commit fb534b7

Please sign in to comment.