mermaid-js / mermaid

Generation of diagrams like flowcharts or sequence diagrams from text in a similar manner as markdown
https://mermaid.js.org
MIT License
72.25k stars 6.58k forks source link

src/mermaid.js generates bad code #297

Closed LarryKlugerDS closed 6 years ago

LarryKlugerDS commented 8 years ago

Current version of src/mermaid.js generates bad code (YUI Compressor doesn't accept it) in dist/mermaid.js

Problem:

   nodes = nodes === undefined ? document.querySelectorAll('.mermaid')
        : typeof nodes === 'string' ? document.querySelectorAll(nodes)
        : nodes instanceof Node ? [nodes]
        /*! Last case  - sequence config was passed pick next */
        : nodes;

Solves problem:
   nodes = nodes === undefined ? document.querySelectorAll('.mermaid')
        : typeof nodes === 'string' ? document.querySelectorAll(nodes)
        : nodes instanceof Node ? [nodes]
        : nodes;  // Last case  - sequence config was passed pick next

Pull request is forthcoming

Log:

yuicompressor-2.4.8.jar dist/mermaid.js -o foo
[ERROR] in dist/mermaid.js
  39901:60:missing : in conditional expression
[ERROR] in dist/mermaid.js
  39902:6:syntax error
[ERROR] in dist/mermaid.js
  1:0:Compilation produced 2 syntax errors.
org.mozilla.javascript.EvaluatorException: Compilation produced 2 syntax errors.
    at com.yahoo.platform.yui.compressor.YUICompressor$1.runtimeError(YUICompressor.java:172)
    at org.mozilla.javascript.Parser.parse(Parser.java:396)
    at org.mozilla.javascript.Parser.parse(Parser.java:340)
    at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:315)
    at com.yahoo.platform.yui.compressor.JavaScriptCompressor.<init>(JavaScriptCompressor.java:536)
    at com.yahoo.platform.yui.compressor.YUICompressor.main(YUICompressor.java:147)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.yahoo.platform.yui.compressor.Bootstrap.main(Bootstrap.java:21)
DSA010328:mermaid larry.kluger$ npm run dist
tylerlong commented 6 years ago

No longer relevant.