Skip to content

Commit c84406f

Browse files
committed
support camelCase assets (close #1029)
1 parent d281abd commit c84406f

File tree

2 files changed

+28
-2
lines changed

2 files changed

+28
-2
lines changed

src/util/options.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -340,13 +340,14 @@ exports.mergeOptions = function merge (parent, child, vm) {
340340
*/
341341

342342
exports.resolveAsset = function resolve (options, type, id) {
343-
var asset = options[type][id]
343+
var camelizedId = _.camelize(id)
344+
var asset = options[type][id] || options[type][camelizedId]
344345
while (
345346
!asset && options._parent &&
346347
(!config.strict || options._repeat)
347348
) {
348349
options = options._parent.$options
349-
asset = options[type][id]
350+
asset = options[type][id] || options[type][camelizedId]
350351
}
351352
return asset
352353
}

test/unit/specs/util/options_spec.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
var _ = require('../../../../src/util')
22
var Vue = require('../../../../src/vue')
33
var merge = _.mergeOptions
4+
var resolveAsset = _.resolveAsset
45

56
describe('Util - Option merging', function () {
67

@@ -303,3 +304,27 @@ describe('Util - Option merging', function () {
303304
})
304305

305306
})
307+
308+
describe('Util - Option resolveAsset', function () {
309+
310+
var vm
311+
beforeEach(function () {
312+
vm = new Vue({
313+
data: {},
314+
components: {
315+
'hyphenated-component': {
316+
template: 'hi'
317+
},
318+
camelCasedComponent: {
319+
template: 'yo'
320+
}
321+
}
322+
})
323+
})
324+
325+
it('resolves', function () {
326+
expect(resolveAsset(vm.$options, 'components', 'hyphenated-component')).toBeTruthy()
327+
expect(resolveAsset(vm.$options, 'components', 'camel-cased-component')).toBeTruthy()
328+
})
329+
330+
})

0 commit comments

Comments
 (0)