Evan You 10 лет назад
Родитель
Сommit
1169252c07
2 измененных файлов с 8 добавлено и 11 удалено
  1. 6 4
      src/compiler/compile-props.js
  2. 2 7
      test/unit/specs/directives/prop_spec.js

+ 6 - 4
src/compiler/compile-props.js

@@ -29,10 +29,12 @@ module.exports = function compileProps (el, propOptions) {
     options = propOptions[i]
     name = options.name
 
-    if (process.env.NODE_ENV !== 'production') {
-      if (name === '$data') {
-        _.deprecation.DATA_AS_PROP()
-      }
+    if (name === '$data') {
+      process.env.NODE_ENV !== 'production' && _.warn(
+        'Do not use $data as prop.'
+      )
+      el.removeAttribute(name)
+      continue
     }
 
     // props could contain dashes, which will be

+ 2 - 7
test/unit/specs/directives/prop_spec.js

@@ -90,7 +90,7 @@ if (_.inBrowser) {
       })
     })
 
-    it('$data as prop', function (done) {
+    it('$data as prop', function () {
       var vm = new Vue({
         el: el,
         template: '<test $data="{{ok}}"></test>',
@@ -106,12 +106,7 @@ if (_.inBrowser) {
           }
         }
       })
-      expect(el.innerHTML).toBe('<test>hihi</test>')
-      vm.ok = { msg: 'what' }
-      _.nextTick(function () {
-        expect(el.innerHTML).toBe('<test>what</test>')
-        done()
-      })
+      expect(hasWarned(_, 'Do not use $data as prop')).toBe(true)
     })
 
     it('explicit one time binding', function (done) {