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

Function variantRecord

javascript/selenium-webdriver/normalize_bidi_ast.mjs:327–340  ·  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

325 * inline group). Returns `{ fields, label }` where label names the variant.
326 */
327function variantRecord(commonFields, entry, defMap, index) {
328 const common = commonFields.map((f) => structuredClone(f))
329 if (isGroupRef(entry)) {
330 const target = defMap.get(entry.Value)
331 const ownFields =
332 target && Array.isArray(target.Properties) ? structuredClone(target.Properties) : [structuredClone({ ...entry })]
333 return { fields: [...common, ...ownFields], label: splitName(entry.Value).local, supersedes: entry.Value }
334 }
335 // inline group: label by its sole distinguishing field when there is one
336 const ownFields = structuredClone(entry.Properties)
337 const named = ownFields.filter((f) => f && typeof f === 'object' && f.Name)
338 const label = named.length === 1 ? pascal(named[0].Name) : `Variant${index}`
339 return { fields: [...common, ...ownFields], label }
340}
341
342/**
343 * 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