Get rid of global.mermaid_config
This commit is contained in:
parent
048b39ae16
commit
7c970d6ff0
|
@ -730,8 +730,6 @@ describe('when rendering a sequenceDiagram', function () {
|
|||
parser.yy = sequenceDb
|
||||
parser.yy.clear()
|
||||
|
||||
delete global.mermaid_config
|
||||
|
||||
NewD3 = function () {
|
||||
const o = {
|
||||
append: function () {
|
||||
|
|
|
@ -66,9 +66,6 @@ const init = function () {
|
|||
: nodes instanceof window.Node ? [nodes]
|
||||
: nodes // Last case - sequence config was passed pick next
|
||||
|
||||
if (typeof global.mermaid_config !== 'undefined') {
|
||||
mermaidAPI.initialize(global.mermaid_config)
|
||||
}
|
||||
logger.debug('Start On Load before: ' + mermaid.startOnLoad)
|
||||
if (typeof mermaid.startOnLoad !== 'undefined') {
|
||||
logger.debug('Start On Load inner: ' + mermaid.startOnLoad)
|
||||
|
@ -133,26 +130,12 @@ const initialize = function (config) {
|
|||
*/
|
||||
const contentLoaded = function () {
|
||||
let config
|
||||
// Check state of start config mermaid namespace
|
||||
if (typeof global.mermaid_config !== 'undefined') {
|
||||
if (global.mermaid_config.htmlLabels === false) {
|
||||
mermaid.htmlLabels = false
|
||||
}
|
||||
}
|
||||
|
||||
if (mermaid.startOnLoad) {
|
||||
// For backwards compatability reasons also check mermaid_config variable
|
||||
if (typeof global.mermaid_config !== 'undefined') {
|
||||
// Check if property startOnLoad is set
|
||||
if (global.mermaid_config.startOnLoad === true) {
|
||||
mermaid.init()
|
||||
}
|
||||
} else {
|
||||
// No config found, do check API config
|
||||
config = mermaidAPI.getConfig()
|
||||
if (config.startOnLoad) {
|
||||
mermaid.init()
|
||||
}
|
||||
// No config found, do check API config
|
||||
config = mermaidAPI.getConfig()
|
||||
if (config.startOnLoad) {
|
||||
mermaid.init()
|
||||
}
|
||||
} else {
|
||||
if (typeof mermaid.startOnLoad === 'undefined') {
|
||||
|
|
|
@ -6,19 +6,8 @@ import flowRenderer from './diagrams/flowchart/flowRenderer'
|
|||
|
||||
describe('when using mermaid and ', function () {
|
||||
describe('when detecting chart type ', function () {
|
||||
it('should not start rendering with mermaid_config.startOnLoad set to false', function () {
|
||||
global.mermaid_config = { startOnLoad: false }
|
||||
|
||||
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'
|
||||
spyOn(mermaid, 'init')
|
||||
mermaid.contentLoaded()
|
||||
expect(mermaid.init).not.toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should not start rendering with mermaid.startOnLoad set to false', function () {
|
||||
mermaid.startOnLoad = false
|
||||
global.mermaid_config = { startOnLoad: true }
|
||||
|
||||
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'
|
||||
spyOn(mermaid, 'init')
|
||||
mermaid.contentLoaded()
|
||||
|
@ -27,14 +16,13 @@ describe('when using mermaid and ', function () {
|
|||
|
||||
it('should start rendering with both startOnLoad set', function () {
|
||||
mermaid.startOnLoad = true
|
||||
global.mermaid_config = { startOnLoad: true }
|
||||
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'
|
||||
spyOn(mermaid, 'init')
|
||||
mermaid.contentLoaded()
|
||||
expect(mermaid.init).toHaveBeenCalled()
|
||||
})
|
||||
|
||||
it('should start rendering with mermaid.startOnLoad set and no mermaid_config defined', function () {
|
||||
it('should start rendering with mermaid.startOnLoad', function () {
|
||||
mermaid.startOnLoad = true
|
||||
document.body.innerHTML = '<div class="mermaid">graph TD;\na;</div>'
|
||||
spyOn(mermaid, 'init')
|
||||
|
@ -52,7 +40,6 @@ describe('when using mermaid and ', function () {
|
|||
|
||||
describe('when calling addEdges ', function () {
|
||||
beforeEach(function () {
|
||||
global.mermaid_config = { startOnLoad: false }
|
||||
flowParser.parser.yy = graphDb
|
||||
graphDb.clear()
|
||||
})
|
||||
|
|
|
@ -4,7 +4,6 @@ import mermaidAPI from './mermaidAPI'
|
|||
describe('when using mermaidAPI and ', function () {
|
||||
describe('doing initialize ', function () {
|
||||
beforeEach(function () {
|
||||
delete global.mermaid_config
|
||||
document.body.innerHTML = ''
|
||||
})
|
||||
|
||||
|
|
Loading…
Reference in New Issue