Skip to content

Commit c580a82

Browse files
committed
Merge branch 'extends' into dev
2 parents 57c27c4 + dcf1fde commit c580a82

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/util/options.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ strats.activate = function (parentVal, childVal) {
149149
*/
150150

151151
function mergeAssets (parentVal, childVal) {
152-
var res = Object.create(parentVal)
152+
var res = Object.create(parentVal || null)
153153
return childVal
154154
? extend(res, guardArrayAssets(childVal))
155155
: res
@@ -333,7 +333,9 @@ export function mergeOptions (parent, child, vm) {
333333
var options = {}
334334
var key
335335
if (child.extends) {
336-
parent = mergeOptions(parent, child.extends, vm)
336+
parent = typeof child.extends === 'function'
337+
? mergeOptions(parent, child.extends.options, vm)
338+
: mergeOptions(parent, child.extends, vm)
337339
}
338340
if (child.mixins) {
339341
for (var i = 0, l = child.mixins.length; i < l; i++) {

test/unit/specs/util/options_spec.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -282,9 +282,9 @@ describe('Util - Option merging', function () {
282282
var f1 = function () {}
283283
var f2 = function () {}
284284
var f3 = function () {}
285-
var componentA = { template: 'foo', methods: { f1: f1, f2: function () {} } }
286-
var componentB = { extends: componentA, methods: { f2: f2 } }
287-
var componentC = { extends: componentB, template: 'bar', methods: { f3: f3 } }
285+
var componentA = Vue.extend({ template: 'foo', methods: { f1: f1, f2: function () {} }})
286+
var componentB = { extends: componentA, methods: { f2: f2 }}
287+
var componentC = { extends: componentB, template: 'bar', methods: { f3: f3 }}
288288
var res = merge({}, componentC)
289289
expect(res.template).toBe('bar')
290290
expect(res.methods.f1).toBe(f1)

0 commit comments

Comments
 (0)