Skip to content

Commit e6b89db

Browse files
committed
Fix unevaluatedProperties edge case bug
1 parent 269e4e2 commit e6b89db

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

lib/keywords/unevaluatedItems.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ const interpret = (unevaluatedItems, instance, context) => {
3333
const simpleApplicator = true;
3434

3535
const plugin = {
36-
beforeSchema(_url, _instance, context) {
36+
beforeSchema(_url, instance, context) {
3737
context.evaluatedItems ??= new Set();
3838
context.schemaEvaluatedItems = new Set();
39+
context.instanceLocation ??= Instance.uri(instance);
3940
},
4041

41-
beforeKeyword(_node, _instance, context, schemaContext) {
42+
beforeKeyword(_node, instance, context, schemaContext) {
4243
context.evaluatedItems = new Set();
4344
context.schemaEvaluatedItems = schemaContext.schemaEvaluatedItems;
45+
context.instanceLocation = Instance.uri(instance);
4446
},
4547

4648
afterKeyword(_node, _instance, context, _valid, schemaContext) {
@@ -49,8 +51,8 @@ const plugin = {
4951
}
5052
},
5153

52-
afterSchema(_node, _instance, context, valid) {
53-
if (valid) {
54+
afterSchema(_node, instance, context, valid) {
55+
if (valid && Instance.uri(instance) === context.instanceLocation) {
5456
for (const property of context.schemaEvaluatedItems) {
5557
context.evaluatedItems.add(property);
5658
}

lib/keywords/unevaluatedProperties.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,16 @@ const interpret = (unevaluatedProperties, instance, context) => {
3333
const simpleApplicator = true;
3434

3535
const plugin = {
36-
beforeSchema(_url, _instance, context) {
36+
beforeSchema(_url, instance, context) {
3737
context.evaluatedProperties ??= new Set();
3838
context.schemaEvaluatedProperties = new Set();
39+
context.instanceLocation ??= Instance.uri(instance);
3940
},
4041

41-
beforeKeyword(_node, _instance, context, schemaContext) {
42+
beforeKeyword(_node, instance, context, schemaContext) {
4243
context.evaluatedProperties = new Set();
4344
context.schemaEvaluatedProperties = schemaContext.schemaEvaluatedProperties;
45+
context.instanceLocation = Instance.uri(instance);
4446
},
4547

4648
afterKeyword(_node, _instance, context, _valid, schemaContext) {
@@ -49,8 +51,8 @@ const plugin = {
4951
}
5052
},
5153

52-
afterSchema(_node, _instance, context, valid) {
53-
if (valid) {
54+
afterSchema(_node, instance, context, valid) {
55+
if (valid && Instance.uri(instance) === context.instanceLocation) {
5456
for (const property of context.schemaEvaluatedProperties) {
5557
context.evaluatedProperties.add(property);
5658
}

0 commit comments

Comments
 (0)