diff --git a/src/util/options.js b/src/util/options.js index bb17732aa..b80cabf81 100644 --- a/src/util/options.js +++ b/src/util/options.js @@ -231,7 +231,7 @@ function guardComponents (options) { } def = components[key] if (_.isPlainObject(def)) { - def.id = def.id || key + def.name = def.name || key components[key] = def._Ctor || (def._Ctor = _.Vue.extend(def)) } } @@ -280,10 +280,10 @@ function guardArrayAssets (assets) { var asset while (i--) { asset = assets[i] - var id = asset.id || (asset.options && asset.options.id) + var id = asset.name || (asset.options && asset.options.name) if (!id) { process.env.NODE_ENV !== 'production' && _.warn( - 'Array-syntax assets must provide an id field.' + 'Array-syntax assets must provide a "name" field.' ) } else { res[id] = asset diff --git a/test/unit/specs/util/options_spec.js b/test/unit/specs/util/options_spec.js index 9238fec0f..8a904b131 100644 --- a/test/unit/specs/util/options_spec.js +++ b/test/unit/specs/util/options_spec.js @@ -123,7 +123,7 @@ describe('Util - Option merging', function () { } }) expect(typeof res.components.test).toBe('function') - expect(res.components.test.options.id).toBe('test') + expect(res.components.test.options.name).toBe('test') expect(res.components.test.super).toBe(Vue) }) @@ -282,11 +282,12 @@ describe('Util - Option merging', function () { } } var b = { - components: [{ id: 'b' }] + components: [{ name: 'b' }] } var res = merge(a, b) expect(res.components.a).toBe(a.components.a) // b.components is guarded and converted to object hash + expect(res.components.b).toBeTruthy() expect(res.components.b).toBe(b.components.b) }) @@ -300,7 +301,7 @@ describe('Util - Option merging', function () { components: [{}] } merge(a, b) - expect(hasWarned(_, 'must provide an id')).toBe(true) + expect(hasWarned(_, 'must provide a "name" field')).toBe(true) }) })