From 083bafdb33427fb9733229244da95c7b81c1dbb9 Mon Sep 17 00:00:00 2001 From: Ben Ogle Date: Tue, 27 Jan 2015 16:47:03 -0800 Subject: [PATCH] =?UTF-8?q?Handle=20unschema=E2=80=99d=20items=20in=20obje?= =?UTF-8?q?cts.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is required for packages that still use configDefaults --- spec/config-spec.coffee | 7 +++++++ src/config.coffee | 17 +++++++++++------ 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/spec/config-spec.coffee b/spec/config-spec.coffee index 6370eb0b6..778437960 100644 --- a/spec/config-spec.coffee +++ b/spec/config-spec.coffee @@ -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 diff --git a/src/config.coffee b/src/config.coffee index 2666584c3..5ea29ef7b 100644 --- a/src/config.coffee +++ b/src/config.coffee @@ -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':