(
group: AnyParseNode | null | undefined,
options: Options,
baseOptions?: Options,
)
| 257 | * between parents and children. |
| 258 | */ |
| 259 | export const buildGroup = function( |
| 260 | group: AnyParseNode | null | undefined, |
| 261 | options: Options, |
| 262 | baseOptions?: Options, |
| 263 | ): HtmlDomNode { |
| 264 | if (!group) { |
| 265 | return makeSpan(); |
| 266 | } |
| 267 | |
| 268 | if (groupBuilders[group.type]) { |
| 269 | // TODO(ts): groupBuilders is Record<string, HtmlBuilder<any>>; |
| 270 | // a type-safe registry would need a mapped type keyed by NodeType. |
| 271 | let groupNode: HtmlDomNode = groupBuilders[group.type](group, options); |
| 272 | |
| 273 | // If the size changed between the parent and the current group, account |
| 274 | // for that size difference. |
| 275 | if (baseOptions && options.size !== baseOptions.size) { |
| 276 | groupNode = makeSpan(options.sizingClasses(baseOptions), |
| 277 | [groupNode], options); |
| 278 | |
| 279 | const multiplier = |
| 280 | options.sizeMultiplier / baseOptions.sizeMultiplier; |
| 281 | |
| 282 | groupNode.height *= multiplier; |
| 283 | groupNode.depth *= multiplier; |
| 284 | } |
| 285 | |
| 286 | return groupNode; |
| 287 | } else { |
| 288 | throw new ParseError( |
| 289 | "Got group of unknown type: '" + group.type + "'"); |
| 290 | } |
| 291 | }; |
| 292 | |
| 293 | /** |
| 294 | * Combine an array of HTML DOM nodes (e.g., the output of `buildExpression`) |
no test coverage detected
searching dependent graphs…