-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2a21d56
commit 02894e1
Showing
1 changed file
with
8 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -125,16 +125,19 @@ var _ = _self.Prism = { | |
}, | ||
|
||
// Traverse a language definition with Depth First Search | ||
DFS: function(o, callback, type) { | ||
DFS: function(o, callback, type, visited) { | ||
visited = visited || {}; | ||
for (var i in o) { | ||
if (o.hasOwnProperty(i)) { | ||
callback.call(o, i, o[i], type || i); | ||
|
||
if (_.util.type(o[i]) === 'Object') { | ||
_.languages.DFS(o[i], callback); | ||
if (_.util.type(o[i]) === 'Object' && !visited[o[i]]) { | ||
visited[o[i]] = true; | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
zeitgeist87
Author
Collaborator
|
||
_.languages.DFS(o[i], callback, null, visited); | ||
} | ||
else if (_.util.type(o[i]) === 'Array') { | ||
_.languages.DFS(o[i], callback, i); | ||
else if (_.util.type(o[i]) === 'Array' && !visited[o[i]]) { | ||
visited[o[i]] = true; | ||
_.languages.DFS(o[i], callback, i, visited); | ||
} | ||
} | ||
} | ||
|
Are we using an object as the key here and below? Does this work?