MCPcopy Create free account
hub / github.com/json-editor/json-editor / evaluateDependencies

Method evaluateDependencies

src/editor.js:125–169  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

123 }
124
125 evaluateDependencies () {
126 const wrapper = this.container || this.control
127 if (!wrapper || this.jsoneditor === null) {
128 return
129 }
130
131 const deps = this.options.dependencies
132 if (!deps) {
133 return
134 }
135
136 // Assume true and set to false if any unmet dependencies are found
137 const previousStatus = this.dependenciesFulfilled
138 this.dependenciesFulfilled = true
139
140 Object.keys(deps).forEach(dependency => {
141 let path
142 const isFullPath = dependency.startsWith(this.jsoneditor.root.path)
143
144 if (isFullPath) {
145 path = dependency
146 } else {
147 path = this.path.split('.')
148 path[path.length - 1] = dependency
149 path = path.join('.')
150 }
151
152 const choices = deps[dependency]
153 this.checkDependency(path, choices)
154 })
155
156 if (this.dependenciesFulfilled !== previousStatus) {
157 this.notify()
158 }
159
160 let displayMode = this.dependenciesFulfilled ? 'block' : 'none'
161
162 if (this.options.hidden) {
163 displayMode = 'none'
164 }
165
166 if (wrapper.tagName === 'TD') {
167 Object.keys(wrapper.childNodes).forEach(child => (wrapper.childNodes[child].style.display = displayMode))
168 } else wrapper.style.display = displayMode
169 }
170
171 checkDependency (path, choices) {
172 if (this.path === path || this.jsoneditor === null) {

Callers 1

registerDependenciesMethod · 0.95

Calls 2

checkDependencyMethod · 0.95
notifyMethod · 0.95

Tested by

no test coverage detected