Skip to content

Commit

Permalink
bug fix: references of props do not shadow label (#260)
Browse files Browse the repository at this point in the history
  • Loading branch information
dqnykamp authored Nov 24, 2024
1 parent 0a0ab0d commit 7a75342
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 0 deletions.
13 changes: 13 additions & 0 deletions packages/doenetml-worker/src/Dependencies.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
Expand Down
29 changes: 29 additions & 0 deletions packages/doenetml-worker/src/test/graphical/labels.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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: `
<graph>
<line name="line" slope="1"><label>L</label></line>
<line name="l" labelIsName slope="-2" />
<point name="P1" copySource="line.point1" />
<point name="P2" copySource="line.point2" />
$l.points{assignNames="P3 P4"}
<point name="P5" copySource="line.point1" link="false" />
<point name="P6" copySource="line.point2" link="false" />
$l.points{assignNames="P7 P8" link="false"}
</graph>`,
});

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("");
});
});

0 comments on commit 7a75342

Please sign in to comment.