mirror of
https://github.com/atom/atom.git
synced 2026-01-23 05:48:10 -05:00
Handle unschema’d items in objects.
This is required for packages that still use configDefaults
This commit is contained in:
@@ -1145,6 +1145,11 @@ describe "Config", ->
|
||||
expect(atom.config.get('foo.bar.str')).toBe 'global'
|
||||
expect(atom.config.get('foo.bar.str', scope: ['.source.js'])).toBe 'scoped'
|
||||
|
||||
expect(atom.config.set('foo.bar.noschema', 'nsGlobal')).toBe true
|
||||
expect(atom.config.set('foo.bar.noschema', 'nsScoped', scopeSelector: '.source.js')).toBe true
|
||||
expect(atom.config.get('foo.bar.noschema')).toBe 'nsGlobal'
|
||||
expect(atom.config.get('foo.bar.noschema', scope: ['.source.js'])).toBe 'nsScoped'
|
||||
|
||||
expect(atom.config.set('foo.bar.int', 'nope')).toBe true
|
||||
expect(atom.config.set('foo.bar.int', 'notanint', scopeSelector: '.source.js')).toBe true
|
||||
expect(atom.config.set('foo.bar.int', 23, scopeSelector: '.source.coffee')).toBe true
|
||||
@@ -1156,6 +1161,8 @@ describe "Config", ->
|
||||
|
||||
expect(atom.config.get('foo.bar.str')).toBe 'global'
|
||||
expect(atom.config.get('foo.bar.str', scope: ['.source.js'])).toBe 'scoped'
|
||||
expect(atom.config.get('foo.bar.noschema')).toBe 'nsGlobal'
|
||||
expect(atom.config.get('foo.bar.noschema', scope: ['.source.js'])).toBe 'nsScoped'
|
||||
|
||||
expect(atom.config.get('foo.bar.int')).toBe 2
|
||||
expect(atom.config.get('foo.bar.int', scope: ['.source.js'])).toBe 2
|
||||
|
||||
@@ -1144,12 +1144,17 @@ Config.addSchemaEnforcers
|
||||
return value unless schema.properties?
|
||||
|
||||
newValue = {}
|
||||
for prop, childSchema of schema.properties
|
||||
continue unless value.hasOwnProperty(prop)
|
||||
try
|
||||
newValue[prop] = @executeSchemaEnforcers("#{keyPath}.#{prop}", value[prop], childSchema)
|
||||
catch error
|
||||
console.warn "Error setting item in object: #{error.message}"
|
||||
for prop, propValue of value
|
||||
childSchema = schema.properties[prop]
|
||||
if childSchema?
|
||||
try
|
||||
newValue[prop] = @executeSchemaEnforcers("#{keyPath}.#{prop}", propValue, childSchema)
|
||||
catch error
|
||||
console.warn "Error setting item in object: #{error.message}"
|
||||
else
|
||||
# Just pass through un-schema'd values
|
||||
newValue[prop] = propValue
|
||||
|
||||
newValue
|
||||
|
||||
'array':
|
||||
|
||||
Reference in New Issue
Block a user