From e91229f69f6bd2372dbc4d35b46108000fbc3cd7 Mon Sep 17 00:00:00 2001 From: Tyler Long Date: Tue, 11 Apr 2017 23:31:59 +0800 Subject: [PATCH] Fix style issue of mermaid.js and mermaidAPI.js --- src/mermaid.js | 6 +++--- src/mermaidAPI.js | 16 ++++++++-------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/mermaid.js b/src/mermaid.js index e9236f708..f7c99ee5c 100644 --- a/src/mermaid.js +++ b/src/mermaid.js @@ -64,12 +64,12 @@ var init = function () { } nodes = nodes === undefined ? document.querySelectorAll('.mermaid') : typeof nodes === 'string' ? document.querySelectorAll(nodes) - : nodes instanceof Node ? [nodes] + : nodes instanceof window.Node ? [nodes] : nodes // Last case - sequence config was passed pick next var i - if (typeof mermaid_config !== 'undefined') { + if (typeof global.mermaid_config !== 'undefined') { mermaidAPI.initialize(global.mermaid_config) } log.debug('Start On Load before: ' + global.mermaid.startOnLoad) @@ -204,7 +204,7 @@ exports.parseError = global.mermaid.parseError exports.contentLoaded = function () { var config // Check state of start config mermaid namespace - if (typeof mermaid_config !== 'undefined') { + if (typeof global.mermaid_config !== 'undefined') { if (equals(false, global.mermaid_config.htmlLabels)) { global.mermaid.htmlLabels = false } diff --git a/src/mermaidAPI.js b/src/mermaidAPI.js index 217f708e2..14fd18671 100644 --- a/src/mermaidAPI.js +++ b/src/mermaidAPI.js @@ -36,7 +36,7 @@ var gitGraphRenderer = require('./diagrams/gitGraph/gitGraphRenderer') var gitGraphAst = require('./diagrams/gitGraph/gitGraphAst') var d3 = require('./d3') -SVGElement.prototype.getTransformToElement = SVGElement.prototype.getTransformToElement || function (toElement) { +window.SVGElement.prototype.getTransformToElement = window.SVGElement.prototype.getTransformToElement || function (toElement) { return toElement.getScreenCTM().inverse().multiply(this.getScreenCTM()) } /** @@ -222,15 +222,15 @@ var config = { }], // Monday a week ['w. %U', function (d) { - return d.getDay() == 1 + return d.getDay() === 1 }], // Day within a week (not monday) ['%a %d', function (d) { - return d.getDay() && d.getDate() != 1 + return d.getDay() && d.getDate() !== 1 }], // within a month ['%b %d', function (d) { - return d.getDate() != 1 + return d.getDate() !== 1 }], // Month ['%m-%y', function (d) { @@ -316,7 +316,7 @@ exports.encodeEntities = function (text) { return innerTxt }) - txt = txt.replace(/#\w+\;/g, function (s) { + txt = txt.replace(/#\w+;/g, function (s) { var innerTxt = s.substring(1, s.length - 1) var isInt = /^\+?\d+$/.test(innerTxt) @@ -333,10 +333,10 @@ exports.encodeEntities = function (text) { exports.decodeEntities = function (text) { var txt = text - txt = txt.replace(/\fl\°\°/g, function () { + txt = txt.replace(/fl°°/g, function () { return '&#' }) - txt = txt.replace(/\fl\°/g, function () { + txt = txt.replace(/fl°/g, function () { return '&' }) txt = txt.replace(/¶ß/g, function () { @@ -380,7 +380,7 @@ var render = function (id, txt, cb, container) { .attr('xmlns', 'http://www.w3.org/2000/svg') .append('g') } else { - var element = document.querySelector('#' + 'd' + id) + const element = document.querySelector('#' + 'd' + id) if (element) { element.innerHTML = '' }