15
15
16
16
import _ from "underscore" ;
17
17
18
- import { mapObject , applyDefaultsToWidget } from "@khanacademy/perseus-core" ;
19
-
20
18
import { mapObject } from "./utils/objective_" ;
21
19
import * as Widgets from "./widgets/core-widget-registry" ;
22
20
@@ -30,47 +28,18 @@ const deepCallbackFor = function (
30
28
optionsCallback : ( arg1 : any ) => void ,
31
29
) {
32
30
const deepCallback = function ( widgetInfo : any , widgetId : string ) {
33
- // This doesn't modify the widget info if the widget info
34
- // is at a later version than is supported, which is important
35
- // for our latestVersion test below.
36
- const upgradedWidgetInfo = applyDefaultsToWidget ( widgetInfo ) ;
37
- const latestVersion = Widgets . getVersion ( upgradedWidgetInfo . type ) ;
38
-
39
- // Only traverse our children if we can understand this version
40
- // of the widget props.
41
- // TODO(aria): This will break if the traversal code assumes that
42
- // any props that usually get defaulted in are present. That is,
43
- // it can fail on minor version upgrades.
44
- // For this reason, and because the upgrade code doesn't handle
45
- // minor versions correctly (it doesn't report anything useful
46
- // about what minor version a widget is actually at, since it
47
- // doesn't have meaning in the context of upgrades), we
48
- // just check the major version here.
49
- // TODO(aria): This is seriously quirky and would be unpleasant
50
- // to think about while writing traverseChildWidgets code. Please
51
- // make all of this a little tighter.
52
- // I think once we use react class defaultProps instead of relying
53
- // on getDefaultProps, this will become easier.
54
- let newWidgetInfo ;
55
- if (
56
- latestVersion &&
57
- upgradedWidgetInfo . version ?. major === latestVersion . major
58
- ) {
59
- newWidgetInfo = Widgets . traverseChildWidgets (
60
- upgradedWidgetInfo ,
61
- ( rendererOptions ) => {
62
- return traverseRenderer (
63
- rendererOptions ,
64
- contentCallback ,
65
- // so that we traverse grandchildren, too:
66
- deepCallback ,
67
- optionsCallback ,
68
- ) ;
69
- } ,
70
- ) ;
71
- } else {
72
- newWidgetInfo = upgradedWidgetInfo ;
73
- }
31
+ const newWidgetInfo = Widgets . traverseChildWidgets (
32
+ widgetInfo ,
33
+ ( rendererOptions ) => {
34
+ return traverseRenderer (
35
+ rendererOptions ,
36
+ contentCallback ,
37
+ // so that we traverse grandchildren, too:
38
+ deepCallback ,
39
+ optionsCallback ,
40
+ ) ;
41
+ } ,
42
+ ) ;
74
43
75
44
const userWidgetInfo = widgetCallback ( newWidgetInfo , widgetId ) ;
76
45
if ( userWidgetInfo !== undefined ) {
0 commit comments