From 2d12ebb1dff3abba8cdc4495a77b18cf72401a4e Mon Sep 17 00:00:00 2001 From: nightwing Date: Sun, 21 Dec 2014 12:21:05 +0400 Subject: [PATCH] improve global access warning in the demo --- demo/kitchen-sink/dev_util.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/demo/kitchen-sink/dev_util.js b/demo/kitchen-sink/dev_util.js index ae9200b7..8dab857c 100644 --- a/demo/kitchen-sink/dev_util.js +++ b/demo/kitchen-sink/dev_util.js @@ -31,13 +31,15 @@ define(function(require, exports, module) { var dom = require("ace/lib/dom"); var Range = require("ace/range").Range; -// allow easy access to ace in console, but not in ace code which uses strict -function isStrict() { - try { return !arguments.callee.caller.caller.caller} - catch(e){ return true } -} function warn() { - if (isStrict()) { + var s = (new Error()).stack || ""; + s = s.split("\n"); + if (s[1] == "Error") s.shift(); // remove error description on chrome + s.shift(); // remove warn + s.shift(); // remove the getter + s = s.join("\n"); + // allow easy access to ace in console, but not in ace code + if (!/at Object.InjectedScript.|@debugger eval|snippets:\/{3}/.test(s)) { console.error("trying to access to global variable"); } }