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

Function using

src/forest/method/using.ts:40–132  ·  view source on GitHub ↗
(node: DOMElement, opts: any)

Source from the content-addressed store, hash-verified

38 },
39): void
40export function using(node: DOMElement, opts: any): void {
41 let cb: () => any
42 let onComplete: (() => void) | undefined
43 let env: {
44 document: Document
45 }
46 let hydrate: boolean
47 let onRoot: ((config: {template: Template; leaf: Leaf}) => void) | undefined
48 let scope: Scope
49 if (typeof opts === 'function') {
50 cb = opts
51 env = getDefaultEnv()
52 hydrate = false
53 } else if (opts) {
54 cb = opts.fn
55 env = opts.env ? opts.env : getDefaultEnv()
56 hydrate = opts.hydrate
57 onComplete = opts.onComplete
58 onRoot = opts.onRoot
59 scope = opts.scope
60 } else throw Error('using() second argument is missing')
61 assert(node, 'using() first argument is missing')
62 const root: Root = {
63 scope: scope!,
64 env,
65 activeSpawns: new Set(),
66 childSpawns: {},
67 leafOps: {},
68 }
69 const namespaceURI = node.namespaceURI
70 const tag = node.tagName.toLowerCase()
71 const ns: NSType =
72 namespaceURI === 'http://www.w3.org/2000/svg'
73 ? 'svg'
74 : tag === 'foreignobject'
75 ? 'foreignObject'
76 : 'html'
77 const draft: UsingDraft = {
78 type: 'using',
79 childTemplates: [],
80 childCount: 0,
81 inParentIndex: -1,
82 }
83 const usingTemplate = createTemplate({
84 name: 'using',
85 draft,
86 isSvgRoot: tag === 'svg',
87 namespace: ns,
88 fn(_, {mount}) {
89 cb()
90 mount.watch(mountFn.using)
91 },
92 env,
93 })
94
95 const usingBlock: UsingBlock = {
96 type: 'using',
97 child: [],

Callers

nothing calls this directly

Calls 8

assertFunction · 0.90
createTemplateFunction · 0.90
createOpQueueFunction · 0.90
spawnFunction · 0.90
createOpGroupFunction · 0.90
getDefaultEnvFunction · 0.85
onRootFunction · 0.50
rsFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…