Skip to content

Commit

Permalink
Adding comments
Browse files Browse the repository at this point in the history
  • Loading branch information
SonicScrewdriver committed Nov 18, 2024
1 parent 9d2c704 commit 46ba385
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
16 changes: 9 additions & 7 deletions packages/perseus/src/renderer-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,16 +66,18 @@ export function scorePerseusItem(
strings: PerseusStrings,
locale: string,
): PerseusScore {
// There seems to be a chance that PerseusRenderer.widgets might include
// widget data for widgets that are not in PerseusRenderer.content,
// so this checks that the widgets are being used before scoring them
const mustConvertRenderData = conversionRequired(perseusRenderData);
const convertedRenderData = mustConvertRenderData
// Check if the PerseusRenderer object contains any deprecated widgets that need to be converted
const mustConvertData = conversionRequired(perseusRenderData);
const convertedRenderData = mustConvertData
? convertDeprecatedWidgets(perseusRenderData) // Convert deprecated widgets to their modern equivalents
: perseusRenderData;
const convertedUserInputMap = mustConvertRenderData
? convertUserInputData(userInputMap)
const convertedUserInputMap = mustConvertData
? convertUserInputData(userInputMap) // Convert deprecated user input data keys to their modern equivalents
: userInputMap;

// There seems to be a chance that PerseusRenderer.widgets might include
// widget data for widgets that are not in PerseusRenderer.content,
// so this checks that the widgets are being used before scoring them
const usedWidgetIds = getWidgetIdsFromContent(convertedRenderData.content);
const scores = scoreWidgetsFunctional(
convertedRenderData.widgets,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export const conversionRequired = (json: PerseusRenderer): boolean => {
return false;
};

// Convert the user input data keys from input-number to numeric-input
export const convertUserInputData = (
userInputMap: UserInputMap,
): UserInputMap => {
Expand Down

0 comments on commit 46ba385

Please sign in to comment.