Skip to content

Commit

Permalink
Merge pull request #135 from bollwyvl/patch-2
Browse files Browse the repository at this point in the history
Allow other forms of node selection for init()
  • Loading branch information
knsv committed Mar 10, 2015
2 parents 34ee8a0 + d61aac3 commit b0cf983
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,25 @@ var parse = function(text){
*
* 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.
*
*
* 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;
* a(Find elements)-->b{Processed};
* b-->|Yes|c(Leave element);
* 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 i;

Expand Down

0 comments on commit b0cf983

Please sign in to comment.