Przeglądaj źródła

fix extends test

Evan You 10 lat temu
rodzic
commit
dcf1fdebc1
2 zmienionych plików z 4 dodań i 5 usunięć
  1. 1 1
      src/util/options.js
  2. 3 4
      test/unit/specs/util/options_spec.js

+ 1 - 1
src/util/options.js

@@ -149,7 +149,7 @@ strats.activate = function (parentVal, childVal) {
  */
 
 function mergeAssets (parentVal, childVal) {
-  var res = Object.create(parentVal)
+  var res = Object.create(parentVal || null)
   return childVal
     ? extend(res, guardArrayAssets(childVal))
     : res

+ 3 - 4
test/unit/specs/util/options_spec.js

@@ -282,10 +282,9 @@ describe('Util - Option merging', function () {
     var f1 = function () {}
     var f2 = function () {}
     var f3 = function () {}
-    var componentA = function () {}
-    componentA.options = { template: 'foo', methods: { f1: f1, f2: function () {} } }
-    var componentB = { extends: componentA, methods: { f2: f2 } }
-    var componentC = { extends: componentB, template: 'bar', methods: { f3: f3 } }
+    var componentA = Vue.extend({ template: 'foo', methods: { f1: f1, f2: function () {} }})
+    var componentB = { extends: componentA, methods: { f2: f2 }}
+    var componentC = { extends: componentB, template: 'bar', methods: { f3: f3 }}
     var res = merge({}, componentC)
     expect(res.template).toBe('bar')
     expect(res.methods.f1).toBe(f1)