@@ -92,14 +92,13 @@ export class AbstractEditor {
9292 return
9393 }
9494
95- const self = this
9695 Object . keys ( deps ) . forEach ( dependency => {
97- let path = self . path . split ( '.' )
96+ let path = this . path . split ( '.' )
9897 path [ path . length - 1 ] = dependency
9998 path = path . join ( '.' )
10099 const choices = deps [ dependency ]
101- self . jsoneditor . watch ( path , ( ) => {
102- self . checkDependency ( path , choices )
100+ this . jsoneditor . watch ( path , ( ) => {
101+ this . checkDependency ( path , choices )
103102 } )
104103 } )
105104 }
@@ -110,7 +109,6 @@ export class AbstractEditor {
110109 return
111110 }
112111
113- const self = this
114112 const editor = this . jsoneditor . getEditor ( path )
115113 const value = editor ? editor . getValue ( ) : undefined
116114 const previousStatus = this . dependenciesFulfilled
@@ -121,7 +119,7 @@ export class AbstractEditor {
121119 } else if ( Array . isArray ( choices ) ) {
122120 choices . some ( choice => {
123121 if ( value === choice ) {
124- self . dependenciesFulfilled = true
122+ this . dependenciesFulfilled = true
125123 return true
126124 }
127125 } )
@@ -134,10 +132,10 @@ export class AbstractEditor {
134132 return false
135133 }
136134 if ( ! hasOwnProperty ( value , key ) || choices [ key ] !== value [ key ] ) {
137- self . dependenciesFulfilled = false
135+ this . dependenciesFulfilled = false
138136 return true
139137 }
140- self . dependenciesFulfilled = true
138+ this . dependenciesFulfilled = true
141139 } )
142140 }
143141 } else if ( typeof choices === 'string' || typeof choices === 'number' ) {
@@ -169,17 +167,17 @@ export class AbstractEditor {
169167
170168 setOptInCheckbox ( header ) {
171169 /* the active/deactive checbox control. */
172- const self = this
170+
173171 this . optInCheckbox = document . createElement ( 'input' )
174172 this . optInCheckbox . setAttribute ( 'type' , 'checkbox' )
175173 this . optInCheckbox . setAttribute ( 'style' , 'margin: 0 10px 0 0;' )
176174 this . optInCheckbox . classList . add ( 'json-editor-opt-in' )
177175
178176 this . optInCheckbox . addEventListener ( 'click' , ( ) => {
179- if ( self . isActive ( ) ) {
180- self . deactivate ( )
177+ if ( this . isActive ( ) ) {
178+ this . deactivate ( )
181179 } else {
182- self . activate ( )
180+ this . activate ( )
183181 }
184182 } )
185183
@@ -211,21 +209,19 @@ export class AbstractEditor {
211209 }
212210
213211 setupWatchListeners ( ) {
214- const self = this
215-
216212 /* Watched fields */
217213 this . watched = { }
218214 if ( this . schema . vars ) this . schema . watch = this . schema . vars
219215 this . watched_values = { }
220216 this . watch_listener = ( ) => {
221- if ( self . refreshWatchedFieldValues ( ) ) {
222- self . onWatchedFieldChange ( )
217+ if ( this . refreshWatchedFieldValues ( ) ) {
218+ this . onWatchedFieldChange ( )
223219 }
224220 }
225221
226222 if ( hasOwnProperty ( this . schema , 'watch' ) ) {
227223 let path ; let pathParts ; let first ; let root ; let adjustedPath
228- const myPath = self . container . getAttribute ( 'data-schemapath' )
224+ const myPath = this . container . getAttribute ( 'data-schemapath' )
229225
230226 Object . keys ( this . schema . watch ) . forEach ( name => {
231227 path = this . schema . watch [ name ]
@@ -234,23 +230,23 @@ export class AbstractEditor {
234230 pathParts = [ path [ 0 ] ] . concat ( path [ 1 ] . split ( '.' ) )
235231 } else {
236232 pathParts = path . split ( '.' )
237- if ( ! self . theme . closest ( self . container , `[data-schemaid="${ pathParts [ 0 ] } "]` ) ) pathParts . unshift ( '#' )
233+ if ( ! this . theme . closest ( this . container , `[data-schemaid="${ pathParts [ 0 ] } "]` ) ) pathParts . unshift ( '#' )
238234 }
239235 first = pathParts . shift ( )
240236
241- if ( first === '#' ) first = self . jsoneditor . schema . id || 'root'
237+ if ( first === '#' ) first = this . jsoneditor . schema . id || 'root'
242238
243239 /* Find the root node for this template variable */
244- root = self . theme . closest ( self . container , `[data-schemaid="${ first } "]` )
240+ root = this . theme . closest ( this . container , `[data-schemaid="${ first } "]` )
245241 if ( ! root ) throw new Error ( `Could not find ancestor node with id ${ first } ` )
246242
247243 /* Keep track of the root node and path for use when rendering the template */
248244 adjustedPath = `${ root . getAttribute ( 'data-schemapath' ) } .${ pathParts . join ( '.' ) } `
249245
250- if ( myPath . startsWith ( adjustedPath ) ) self . watchLoop = true
251- self . jsoneditor . watch ( adjustedPath , self . watch_listener )
246+ if ( myPath . startsWith ( adjustedPath ) ) this . watchLoop = true
247+ this . jsoneditor . watch ( adjustedPath , this . watch_listener )
252248
253- self . watched [ name ] = adjustedPath
249+ this . watched [ name ] = adjustedPath
254250 } )
255251 }
256252
@@ -402,13 +398,12 @@ export class AbstractEditor {
402398 if ( ! this . watched_values ) return
403399 const watched = { }
404400 let changed = false
405- const self = this
406401
407402 if ( this . watched ) {
408403 Object . keys ( this . watched ) . forEach ( name => {
409- const editor = self . jsoneditor . getEditor ( this . watched [ name ] )
404+ const editor = this . jsoneditor . getEditor ( this . watched [ name ] )
410405 const val = editor ? editor . getValue ( ) : null
411- if ( self . watched_values [ name ] !== val ) changed = true
406+ if ( this . watched_values [ name ] !== val ) changed = true
412407 watched [ name ] = val
413408 } )
414409 }
@@ -504,10 +499,9 @@ export class AbstractEditor {
504499 }
505500
506501 destroy ( ) {
507- const self = this
508502 this . unregister ( this )
509503 if ( this . watched ) {
510- Object . values ( this . watched ) . forEach ( adjustedPath => self . jsoneditor . unwatch ( adjustedPath , self . watch_listener ) )
504+ Object . values ( this . watched ) . forEach ( adjustedPath => this . jsoneditor . unwatch ( adjustedPath , this . watch_listener ) )
511505 }
512506
513507 this . watched = null
0 commit comments