MCPcopy
hub / github.com/benjitaylor/agentation / componentCorrelatesWithDOM

Function componentCorrelatesWithDOM

package/src/utils/react-detection.ts:280–305  ·  view source on GitHub ↗

* Check if a component name correlates with any DOM class

(
  componentName: string,
  domClasses: Set<string>,
)

Source from the content-addressed store, hash-verified

278 * Check if a component name correlates with any DOM class
279 */
280function componentCorrelatesWithDOM(
281 componentName: string,
282 domClasses: Set<string>,
283): boolean {
284 const normalized = normalizeComponentName(componentName);
285
286 for (const cls of domClasses) {
287 // Exact match: SideNav -> side-nav
288 if (cls === normalized) return true;
289
290 // Contains match: LinkComponent -> nav-link contains "link"
291 // Split both by hyphens and check for word overlaps
292 const componentWords = normalized.split("-").filter((w) => w.length > 2);
293 const classWords = cls.split("-").filter((w) => w.length > 2);
294
295 for (const cWord of componentWords) {
296 for (const dWord of classWords) {
297 if (cWord === dWord || cWord.includes(dWord) || dWord.includes(cWord)) {
298 return true;
299 }
300 }
301 }
302 }
303
304 return false;
305}
306
307function shouldIncludeComponent(
308 name: string,

Callers 1

shouldIncludeComponentFunction · 0.85

Calls 1

normalizeComponentNameFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…