Skip to content

Commit

Permalink
Fix for issue #311, mermaid will clear div used for rendering initial…
Browse files Browse the repository at this point in the history
…ly in the redner function.
  • Loading branch information
knsv committed Dec 14, 2016
1 parent a179212 commit 046b4fd
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 31 deletions.
2 changes: 1 addition & 1 deletion src/diagrams/flowchart/graphDb.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ exports.addVertex = function (id, text, type, style) {
* @param linktext
*/
exports.addLink = function (start, end, type, linktext) {
log.debug('Got edge', start, end);
log.info('Got edge...', start, end);
var edge = {start: start, end: end, type: undefined, text: ''};
linktext = type.text;

Expand Down
37 changes: 9 additions & 28 deletions src/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ function formatTime(timestamp) {
return t;
}

function format(level) {
const time = formatTime(new Date());
return '%c ' + time +' :%c' + level + ': ';
}

function Log(level) {
this.level = level;
Expand Down Expand Up @@ -81,35 +85,12 @@ function Log(level) {
}
};

this.trace = function(str) {
var args = Array.prototype.slice.call(arguments);
args.unshift(LEVELS.trace);
this.log.apply(this, args);
};

this.debug = function(str) {
var args = Array.prototype.slice.call(arguments);
args.unshift(LEVELS.debug);
this.log.apply(this, args);
};

this.info = function(str) {
var args = Array.prototype.slice.call(arguments);
args.unshift(LEVELS.info);
this.log.apply(this, args);
};
this.trace = window.console.debug.bind(window.console, format('TRACE', name), 'color:grey;', 'color: grey;');
this.debug = window.console.debug.bind(window.console, format('DEBUG', name), 'color:grey;', 'color: green;');
this.info = window.console.debug.bind(window.console, format('INFO', name), 'color:grey;', 'color: blue;');
this.warn = window.console.debug.bind(window.console, format('WARN', name), 'color:grey;', 'color: orange;');
this.error = window.console.debug.bind(window.console, format('ERROR', name), 'color:grey;', 'color: red;');

this.warn = function(str) {
var args = Array.prototype.slice.call(arguments);
args.unshift(LEVELS.warn);
this.log.apply(this, args);
};

this.error = function(str) {
var args = Array.prototype.slice.call(arguments);
args.unshift(LEVELS.error);
this.log.apply(this, args);
};
}

exports.Log = Log;
9 changes: 7 additions & 2 deletions src/mermaidAPI.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,6 @@ exports.decodeEntities = function(text){
return ';';
});



return txt;
};
/**
Expand Down Expand Up @@ -376,6 +374,8 @@ exports.decodeEntities = function(text){
var render = function(id, txt, cb, container){

if(typeof container !== 'undefined'){
container.innerHTML = '';

d3.select(container).append('div')
.attr('id', 'd'+id)
.append('svg')
Expand All @@ -385,6 +385,11 @@ var render = function(id, txt, cb, container){
.append('g');
}
else{
var element = document.querySelector('#' + 'd'+id);
if(element){
element.innerHTML = '';
}

d3.select('body').append('div')
.attr('id', 'd'+id)
.append('svg')
Expand Down

0 comments on commit 046b4fd

Please # to comment.