Skip to content

Commit

Permalink
Should fix
Browse files Browse the repository at this point in the history
  • Loading branch information
IslandRhythms committed Jan 3, 2023
1 parent 36260d6 commit f71ef7a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
'use strict';

const schemaStack = new WeakMap();

module.exports = function autopopulatePlugin(schema, options) {
const pathsToPopulate = getPathsToPopulate(schema);

Expand Down Expand Up @@ -221,9 +223,15 @@ function handleFunction(fn, options) {
}

function eachPathRecursive(schema, handler, path) {

if (schemaStack.has(schema)) {
return;
}
if (!path) {
path = [];
}
schemaStack.set(schema, true);

schema.eachPath(function(pathname, schemaType) {
path.push(pathname);
if (schemaType.schema) {
Expand Down Expand Up @@ -252,7 +260,7 @@ function eachPathRecursive(schema, handler, path) {
}
path.pop();
});

schemaStack.delete(schema);
if (schema.virtuals) {
Object.keys(schema.virtuals).forEach(function(pathname) {
path.push(pathname);
Expand Down

0 comments on commit f71ef7a

Please sign in to comment.