Dev: Add $0 reference

This commit is contained in:
surunzi
2016-05-08 22:23:16 +08:00
parent 1cb3ec05c0
commit 6f2b4b31c9
3 changed files with 30 additions and 3 deletions

View File

@@ -305,7 +305,7 @@ function transMsg(msg)
msg = 'Object ' + JSON.stringify(msg);
}
return util.escape(msg);
return util.escape(util.toStr(msg));
}
function transMultipleMsg(args)
@@ -328,6 +328,5 @@ function transCode(code)
function txtToHtml(str)
{
return str.replace(/\n/g, '<br/>')
.replace(/\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;')
.replace(/ /g, '&nbsp;&nbsp;');
.replace(/\t/g, '&nbsp;&nbsp;&nbsp;&nbsp;');
}

View File

@@ -93,6 +93,7 @@ export default class Elements extends Tool
this._curCssStore = new CssStore(el);
this._highlight.setEl(el);
this._rmDefComputedStyle = true;
window.$0 = el;
this._render();
}

View File

@@ -2380,6 +2380,33 @@ module.exports = (function ()
return exports;
})({});
/* ------------------------------ toStr ------------------------------ */
var toStr = _.toStr = (function (exports)
{
/* Convert value to a string.
*
* |Name |Type |Desc |
* |------------------------------|
* |val |* |Value to convert|
* |return|string|Resulted string |
*
* ```javascript
* toStr(null); // -> ''
* toStr(1); // -> '1'
* toStr(false); // -> 'false'
* toStr([1, 2, 3]); // -> '1,2,3'
* ```
*/
function exports(val)
{
return val == null ? '' : val.toString();
}
return exports;
})({});
/* ------------------------------ trim ------------------------------ */
var trim = _.trim = (function (exports)