MCPcopy Create free account
hub / github.com/effector/effector / spec

Function spec

src/forest/method/spec.ts:19–107  ·  view source on GitHub ↗
(config: {
  attr?: PropertyMap
  data?: PropertyMap
  text?: StoreOrData<DOMProperty> | Array<StoreOrData<DOMProperty>>
  style?: StylePropertyMap
  styleVar?: PropertyMap
  classList?: ClassListArray | ClassListMap
  visible?: Store<boolean>
  handler?:
    | {
        config?: {
          passive?: boolean
          capture?: boolean
          prevent?: boolean
          stop?: boolean
        }
        on: Partial<
          {[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
        >
      }
    | Partial<{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}>
  ɔ?: any
})

Source from the content-addressed store, hash-verified

17import {forIn} from '../forIn'
18
19export function spec(config: {
20 attr?: PropertyMap
21 data?: PropertyMap
22 text?: StoreOrData<DOMProperty> | Array<StoreOrData<DOMProperty>>
23 style?: StylePropertyMap
24 styleVar?: PropertyMap
25 classList?: ClassListArray | ClassListMap
26 visible?: Store<boolean>
27 handler?:
28 | {
29 config?: {
30 passive?: boolean
31 capture?: boolean
32 prevent?: boolean
33 stop?: boolean
34 }
35 on: Partial<
36 {[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}
37 >
38 }
39 | Partial<{[K in keyof HTMLElementEventMap]: Event<HTMLElementEventMap[K]>}>
40 ɔ?: any
41}) {
42 assertClosure(currentTemplate, 'spec')
43 const draft = currentTemplate.draft
44 switch (draft.type) {
45 case 'list':
46 if (config.visible) draft.itemVisible = config.visible
47 return
48 case 'listItem':
49 case 'using':
50 case 'route':
51 case 'rec':
52 case 'recItem':
53 case 'block':
54 case 'blockItem':
55 return
56 }
57 if (config.attr) draft.attr.push(config.attr)
58 if (config.data) draft.data.push(config.data)
59 if ('text' in config) {
60 const text = config.text
61 const firstIndex = draft.childCount
62 if (Array.isArray(text)) {
63 draft.text.push(
64 ...text.map((value, i) => ({
65 index: i + firstIndex,
66 value,
67 })),
68 )
69 draft.childCount += text.length
70 } else {
71 draft.text.push({
72 index: firstIndex,
73 value: text!,
74 })
75 draft.childCount += 1
76 }

Callers 10

textFunction · 0.90
fnFunction · 0.90
index.test.tsFile · 0.90
fnFunction · 0.90
list.test.tsFile · 0.90
visible.test.tsFile · 0.90
fnFunction · 0.90
handler.test.tsFile · 0.90
fnFunction · 0.90
fnFunction · 0.90

Calls 5

assertClosureFunction · 0.90
escapeTagFunction · 0.90
handlerFunction · 0.90
normalizeClassListFunction · 0.85
mapMethod · 0.65

Tested by 4

fnFunction · 0.72
fnFunction · 0.72
fnFunction · 0.72
fnFunction · 0.72

Used in the wild real call sites across dependent graphs

searching dependent graphs…