MCPcopy Create free account
hub / github.com/SeleniumHQ/selenium / variantRecord

Function variantRecord

javascript/selenium-webdriver/normalize_bidi_ast.mjs:311–324  ·  view source on GitHub ↗

* Build the fields for a self-contained variant record: the common fields plus * the variant's own fields (inlined from a referenced record, or taken from an * inline group). Returns `{ fields, label }` where label names the variant.

(commonFields, entry, defMap, index)

Source from the content-addressed store, hash-verified

309 * inline group). Returns `{ fields, label }` where label names the variant.
310 */
311function variantRecord(commonFields, entry, defMap, index) {
312 const common = commonFields.map((f) => structuredClone(f))
313 if (isGroupRef(entry)) {
314 const target = defMap.get(entry.Value)
315 const ownFields =
316 target && Array.isArray(target.Properties) ? structuredClone(target.Properties) : [structuredClone({ ...entry })]
317 return { fields: [...common, ...ownFields], label: splitName(entry.Value).local, supersedes: entry.Value }
318 }
319 // inline group: label by its sole distinguishing field when there is one
320 const ownFields = structuredClone(entry.Properties)
321 const named = ownFields.filter((f) => f && typeof f === 'object' && f.Name)
322 const label = named.length === 1 ? pascal(named[0].Name) : `Variant${index}`
323 return { fields: [...common, ...ownFields], label }
324}
325
326/**
327 * Rewrite variant-union params into a canonical `variable` union of

Callers 1

Calls 6

isGroupRefFunction · 0.85
splitNameFunction · 0.85
pascalFunction · 0.85
filterMethod · 0.80
getMethod · 0.65
mapMethod · 0.45

Tested by

no test coverage detected