mirror of
https://github.com/liriliri/eruda.git
synced 2026-03-20 09:38:37 +08:00
Fix: Dir html element
This commit is contained in:
@@ -246,7 +246,7 @@ function formatJs(code)
|
||||
return highlight(beautify(code), 'js');
|
||||
}
|
||||
|
||||
function formatMsg(args)
|
||||
function formatMsg(args, {htmlForEl = true} = {})
|
||||
{
|
||||
args = substituteStr(args);
|
||||
|
||||
@@ -254,7 +254,7 @@ function formatMsg(args)
|
||||
{
|
||||
let val = args[i];
|
||||
|
||||
if (util.isEl(val))
|
||||
if (util.isEl(val) && htmlForEl)
|
||||
{
|
||||
args[i] = formatEl(val);
|
||||
} else if (util.isFn(val))
|
||||
@@ -282,7 +282,9 @@ function formatMsg(args)
|
||||
|
||||
function formatDir(args)
|
||||
{
|
||||
let msg = formatMsg(args);
|
||||
let msg = formatMsg(args, {
|
||||
htmlForEl: false
|
||||
});
|
||||
|
||||
return msg + '<div class="eruda-json eruda-hidden"></div>'
|
||||
}
|
||||
|
||||
@@ -22,7 +22,13 @@ describe('log', function ()
|
||||
var obj = {a: 1};
|
||||
|
||||
tool.clear().log(obj);
|
||||
expect($tool.find('.eruda-log')).toContainText('Object {a: 1}');
|
||||
expect($tool.find('.eruda-log')).toContainText('Object { a: 1 }');
|
||||
});
|
||||
|
||||
it('dir html element', function ()
|
||||
{
|
||||
tool.clear().dir(document.createElement('script'));
|
||||
expect($tool.find('.eruda-log')).not.toContainText('<script></script>');
|
||||
});
|
||||
|
||||
it('html', function ()
|
||||
@@ -84,7 +90,7 @@ describe('substitution', function ()
|
||||
it('object', function ()
|
||||
{
|
||||
tool.clear().log('Object is %O', {a: 1});
|
||||
expect($tool.find('.eruda-log')).toContainText('Object is {a: 1}');
|
||||
expect($tool.find('.eruda-log')).toContainText('Object is { a: 1 }');
|
||||
|
||||
tool.clear().log('Dom is %o', document.createElement('script'));
|
||||
expect($tool.find('.eruda-log')).toContainText('Dom is <script></script>');
|
||||
|
||||
Reference in New Issue
Block a user