diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2025-02-22 11:26:27 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2025-02-22 13:16:45 -0400 |
commit | 929e8500667012b2b2f5506efbfd10a39134a9cd (patch) | |
tree | b1e9c86bf61d657ffd37e0d665eb54574ce9fdab | |
parent | 475824fb75deadd96be3e815dca5078aca83b2ac (diff) |
yaml, find-reverse: don't double-count inherited specs
-rw-r--r-- | src/data/yaml.js | 7 | ||||
-rw-r--r-- | src/find-reverse.js | 7 |
2 files changed, 14 insertions, 0 deletions
diff --git a/src/data/yaml.js b/src/data/yaml.js index ee65eb7f..69069d66 100644 --- a/src/data/yaml.js +++ b/src/data/yaml.js @@ -695,10 +695,17 @@ export function getAllDataSteps() { const steps = []; + const seenLoadingFns = new Set(); + for (const thingConstructor of Object.values(thingConstructors)) { const getSpecFn = thingConstructor[Thing.getYamlLoadingSpec]; if (!getSpecFn) continue; + // Subclasses can expose literally the same static properties + // by inheritence. We don't want to double-count those! + if (seenLoadingFns.has(getSpecFn)) continue; + seenLoadingFns.add(getSpecFn); + steps.push(getSpecFn({ documentModes, thingConstructors, diff --git a/src/find-reverse.js b/src/find-reverse.js index f31d3c45..6a67ac0f 100644 --- a/src/find-reverse.js +++ b/src/find-reverse.js @@ -17,10 +17,17 @@ export function getAllSpecs({ const specs = {...hardcodedSpecs}; + const seenSpecs = new Set(); + for (const thingConstructor of Object.values(thingConstructors)) { const thingSpecs = thingConstructor[constructorKey]; if (!thingSpecs) continue; + // Subclasses can expose literally the same static properties + // by inheritence. We don't want to double-count those! + if (seenSpecs.has(thingSpecs)) continue; + seenSpecs.add(thingSpecs); + for (const [key, spec] of Object.entries(thingSpecs)) { specs[key] = postprocessSpec(spec, { |