mirror of
https://github.com/mermaid-js/mermaid.git
synced 2025-10-14 19:49:39 +02:00
Merge pull request #135 from bollwyvl/patch-2
Allow other forms of node selection for init()
This commit is contained in:
14
src/main.js
14
src/main.js
@@ -62,7 +62,12 @@ var parse = function(text){
|
|||||||
*
|
*
|
||||||
* The function tags the processed attributes with the attribute data-processed and ignores found elements with the
|
* The function tags the processed attributes with the attribute data-processed and ignores found elements with the
|
||||||
* attribute already set. This way the init function can be triggered several times.
|
* attribute already set. This way the init function can be triggered several times.
|
||||||
*
|
*
|
||||||
|
* Optionally, `init` can accept in the second argument one of the following:
|
||||||
|
* - a DOM Node
|
||||||
|
* - an array of DOM nodes (as would come from a jQuery selector)
|
||||||
|
* - a W3C selector, a la `.mermaid`
|
||||||
|
*
|
||||||
* ```
|
* ```
|
||||||
* graph LR;
|
* graph LR;
|
||||||
* a(Find elements)-->b{Processed};
|
* a(Find elements)-->b{Processed};
|
||||||
@@ -70,7 +75,12 @@ var parse = function(text){
|
|||||||
* c-->|No |d(Transform);
|
* c-->|No |d(Transform);
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
var init = function (sequenceConfig) {
|
var init = function (sequenceConfig, arr) {
|
||||||
|
arr = arr == null ? document.querySelectorAll('.mermaid')
|
||||||
|
: typeof arr === "string" ? document.querySelectorAll(arr)
|
||||||
|
: arr instanceof Node ? [arr]
|
||||||
|
: arr;
|
||||||
|
|
||||||
var arr = document.querySelectorAll('.mermaid');
|
var arr = document.querySelectorAll('.mermaid');
|
||||||
var i;
|
var i;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user