Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug fix: references of props do not shadow label #260

Merged
merged 1 commit into from
Nov 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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("");
});
});
Loading