MCPcopy
hub / github.com/tdewolff/minify / findComponentReference

Function findComponentReference

_benchmarks/sample_echarts.js:81522–81559  ·  view source on GitHub ↗

* Find target component by payload like: * ```js * { legendId: 'some_id', name: 'xxx' } * { toolboxIndex: 1, name: 'xxx' } * { geoName: 'some_name', name: 'xxx' } * ``` * PENDING: at present only * * If not found, return null/undefined.

(payload, ecModel, api)

Source from the content-addressed store, hash-verified

81520
81521
81522 function findComponentReference(payload, ecModel, api) {
81523 var queryOptionMap = preParseFinder(payload).queryOptionMap;
81524 var componentMainType = queryOptionMap.keys()[0];
81525
81526 if (!componentMainType || componentMainType === 'series') {
81527 return;
81528 }
81529
81530 var queryResult = queryReferringComponents(ecModel, componentMainType, queryOptionMap.get(componentMainType), {
81531 useDefault: false,
81532 enableAll: false,
81533 enableNone: false
81534 });
81535 var model = queryResult.models[0];
81536
81537 if (!model) {
81538 return;
81539 }
81540
81541 var view = api.getViewOfComponentModel(model);
81542 var el;
81543 view.group.traverse(function (subEl) {
81544 var tooltipConfig = getECData(subEl).tooltipConfig;
81545
81546 if (tooltipConfig && tooltipConfig.name === payload.name) {
81547 el = subEl;
81548 return true; // stop
81549 }
81550 });
81551
81552 if (el) {
81553 return {
81554 componentMainType: componentMainType,
81555 componentIndex: model.componentIndex,
81556 el: el
81557 };
81558 }
81559 }
81560
81561 function install$A(registers) {
81562 use(install$s);

Callers 1

sample_echarts.jsFile · 0.85

Calls 2

preParseFinderFunction · 0.85
queryReferringComponentsFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…