From 7a75342b4e523ddbecd022a22df1ed890099e6ff Mon Sep 17 00:00:00 2001 From: Duane Nykamp Date: Sat, 23 Nov 2024 21:57:47 -0600 Subject: [PATCH] bug fix: references of props do not shadow label (#260) --- packages/doenetml-worker/src/Dependencies.js | 13 +++++++++ .../src/test/graphical/labels.test.ts | 29 +++++++++++++++++++ 2 files changed, 42 insertions(+) diff --git a/packages/doenetml-worker/src/Dependencies.js b/packages/doenetml-worker/src/Dependencies.js index a0bd89e75..8a75de124 100644 --- a/packages/doenetml-worker/src/Dependencies.js +++ b/packages/doenetml-worker/src/Dependencies.js @@ -7045,6 +7045,19 @@ class ShadowSourceDependency extends Dependency { }; } + // only get sources that are shadowed without propVariable + // unless from implicit prop + if ( + component.shadows.propVariable && + !component.shadows.fromImplicitProp + ) { + return { + success: true, + downstreamComponentNames: [], + downstreamComponentTypes: [], + }; + } + let shadowSourceComponentName = component.shadows.componentName; let shadowSource = this.dependencyHandler._components[shadowSourceComponentName]; diff --git a/packages/doenetml-worker/src/test/graphical/labels.test.ts b/packages/doenetml-worker/src/test/graphical/labels.test.ts index 904dfce85..5d8b594e7 100644 --- a/packages/doenetml-worker/src/test/graphical/labels.test.ts +++ b/packages/doenetml-worker/src/test/graphical/labels.test.ts @@ -890,4 +890,33 @@ describe("Label tests", async () => { "x_a^b or \\(x_c^d\\)", ); }); + + it("props do not shadow label", async () => { + const core = await createTestCore({ + doenetML: ` + + + + + + $l.points{assignNames="P3 P4"} + + + $l.points{assignNames="P7 P8" link="false"} + `, + }); + + const stateVariables = await returnAllStateVariables(core); + + expect(stateVariables["/line"].stateValues.label).eq("L"); + expect(stateVariables["/l"].stateValues.label).eq("l"); + expect(stateVariables["/P1"].stateValues.label).eq(""); + expect(stateVariables["/P2"].stateValues.label).eq(""); + expect(stateVariables["/P3"].stateValues.label).eq(""); + expect(stateVariables["/P4"].stateValues.label).eq(""); + expect(stateVariables["/P5"].stateValues.label).eq(""); + expect(stateVariables["/P6"].stateValues.label).eq(""); + expect(stateVariables["/P7"].stateValues.label).eq(""); + expect(stateVariables["/P8"].stateValues.label).eq(""); + }); });