Bladeren bron

rename paramAttributes -> props

Evan You 11 jaren geleden
bovenliggende
commit
3597675b2b

+ 1 - 1
examples/grid/grid.js

@@ -2,7 +2,7 @@
 Vue.component('demo-grid', {
   template: '#grid-template',
   replace: true,
-  paramAttributes: ['data', 'columns', 'filter-key'],
+  props: ['data', 'columns', 'filter-key'],
   data: function () {
     return {
       data: null,

+ 26 - 26
src/compiler/compile.js

@@ -110,7 +110,7 @@ function teardownDirs (vm, dirs, destroying) {
  * Compile the root element of a component. There are
  * 4 types of things to process here:
  * 
- * 1. paramAttributes on parent container (child scope)
+ * 1. props on parent container (child scope)
  * 2. v-with on parent container (child scope)
  * 3. other attrs on parent container (parent scope)
  * 4. attrs on the component template root node, if
@@ -128,11 +128,11 @@ function compileRoot (el, options) {
   var isBlock = el.nodeType === 11 // DocumentFragment
   var containerAttrs = options._containerAttrs
   var replacerAttrs = options._replacerAttrs
-  var params = options.paramAttributes
-  var paramsLinkFn, withLinkFn, parentLinkFn, replacerLinkFn
-  // 1. paramAttributes
-  paramsLinkFn = params
-    ? compileParamAttributes(el, containerAttrs, params, options)
+  var props = options.props
+  var propsLinkFn, withLinkFn, parentLinkFn, replacerLinkFn
+  // 1. props
+  propsLinkFn = props
+    ? compileProps(el, containerAttrs, props, options)
     : null
   // 2. v-with
   var withName = config.prefix + 'with'
@@ -156,9 +156,9 @@ function compileRoot (el, options) {
     }
   }
   return function rootLinkFn (vm, el, host) {
-    // explicitly passing null to paramAttributes and v-with
+    // explicitly passing null to props and v-with
     // linkers because they don't need a real element
-    if (paramsLinkFn) paramsLinkFn(vm, null)
+    if (propsLinkFn) propsLinkFn(vm, null)
     if (withLinkFn) withLinkFn(vm, null)
     if (parentLinkFn) parentLinkFn(vm.$parent, el, host)
     if (replacerLinkFn) replacerLinkFn(vm, el, host)
@@ -382,28 +382,28 @@ function makeChildLinkFn (linkFns) {
 
 /**
  * Compile param attributes on a root element and return
- * a paramAttributes link function.
+ * a props link function.
  *
  * @param {Element|DocumentFragment} el
  * @param {Object} attrs
- * @param {Array} paramNames
+ * @param {Array} propNames
  * @param {Object} options
- * @return {Function} paramsLinkFn
+ * @return {Function} propsLinkFn
  */
 
-function compileParamAttributes (el, attrs, paramNames, options) {
-  var params = []
-  var i = paramNames.length
+function compileProps (el, attrs, propNames, options) {
+  var props = []
+  var i = propNames.length
   var name, value, param
   while (i--) {
-    name = paramNames[i]
+    name = propNames[i]
     if (/[A-Z]/.test(name)) {
       _.warn(
-        'You seem to be using camelCase for a paramAttribute, ' +
+        'You seem to be using camelCase for a component prop, ' +
         'but HTML doesn\'t differentiate between upper and ' +
         'lower case. You should use hyphen-delimited ' +
         'attribute names. For more info see ' +
-        'http://vuejs.org/api/options.html#paramAttributes'
+        'http://vuejs.org/api/options.html#props'
       )
     }
     value = attrs[name]
@@ -422,30 +422,30 @@ function compileParamAttributes (el, attrs, paramNames, options) {
         param.value = textParser.tokensToExp(tokens)
         param.oneTime = tokens.length === 1 && tokens[0].oneTime
       }
-      params.push(param)
+      props.push(param)
     }
   }
-  return makeParamsLinkFn(params, options)
+  return makeParamsLinkFn(props, options)
 }
 
 /**
  * Build a function that applies param attributes to a vm.
  *
- * @param {Array} params
+ * @param {Array} props
  * @param {Object} options
- * @return {Function} paramsLinkFn
+ * @return {Function} propsLinkFn
  */
 
 var dataAttrRE = /^data-/
 
-function makeParamsLinkFn (params, options) {
+function makeParamsLinkFn (props, options) {
   var def = options.directives['with']
-  return function paramsLinkFn (vm, el) {
-    var i = params.length
+  return function propsLinkFn (vm, el) {
+    var i = props.length
     var param, path
     while (i--) {
-      param = params[i]
-      // params could contain dashes, which will be
+      param = props[i]
+      // props could contain dashes, which will be
       // interpreted as minus calculations by the parser
       // so we need to wrap the path here
       path = _.camelize(param.name.replace(dataAttrRE, ''))

+ 2 - 2
src/instance/scope.js

@@ -25,8 +25,8 @@ exports._initData = function () {
   // proxy data on instance
   var data = this._data
   var i, key
-  // make sure all paramAttributes properties are observed
-  var params = this.$options.paramAttributes
+  // make sure all props properties are observed
+  var params = this.$options.props
   if (params) {
     i = params.length
     while (i--) {

+ 1 - 1
src/util/merge-option.js

@@ -113,7 +113,7 @@ strats.beforeCompile =
 strats.compiled =
 strats.beforeDestroy =
 strats.destroyed =
-strats.paramAttributes = function (parentVal, childVal) {
+strats.props = function (parentVal, childVal) {
   return childVal
     ? parentVal
       ? parentVal.concat(childVal)

+ 1 - 1
test/unit/specs/compiler/compile_spec.js

@@ -157,7 +157,7 @@ if (_.inBrowser) {
     it('param attributes', function () {
       var options = merge(Vue.options, {
         _asComponent: true,
-        paramAttributes: [
+        props: [
           'a',
           'data-some-attr',
           'some-other-attr',

+ 2 - 2
test/unit/specs/directives/component_spec.js

@@ -224,7 +224,7 @@ if (_.inBrowser) {
       })
     })
 
-    it('paramAttributes', function () {
+    it('props', function () {
       var vm = new Vue({
         el: el,
         data: {
@@ -234,7 +234,7 @@ if (_.inBrowser) {
         components: {
           test: {
             template: '<li v-repeat="collection">{{a}}</li>',
-            paramAttributes: ['collection']
+            props: ['collection']
           }
         }
       })

+ 1 - 1
test/unit/specs/directives/if_spec.js

@@ -190,7 +190,7 @@ if (_.inBrowser) {
         template: '<div v-component="test" show="{{show}}">{{a}}</div>',
         components: {
           test: {
-            paramAttributes: ['show'],
+            props: ['show'],
             template: '<div v-if="show"><content></cotent></div>'
           }
         }

+ 1 - 1
test/unit/specs/directives/with_spec.js

@@ -143,7 +143,7 @@ if (_.inBrowser) {
         },
         components: {
           test: {
-            paramAttributes: ['c'],
+            props: ['c'],
             template: '<p>{{b}}</p><p>{{c}}</p>',
             replace: true
           }

+ 2 - 2
test/unit/specs/util/merge-option_spec.js

@@ -13,7 +13,7 @@ describe('Util - Option merging', function () {
     expect(res).toBe(false)
   })
 
-  it('hooks & paramAttributes', function () {
+  it('hooks & props', function () {
     var fn1 = function () {}
     var fn2 = function () {}
     var res
@@ -34,7 +34,7 @@ describe('Util - Option merging', function () {
     expect(res[0]).toBe(fn1)
     expect(res[1]).toBe(fn2)
     // both arrays
-    res = merge({paramAttributes: [1]}, {paramAttributes: [2]}).paramAttributes
+    res = merge({props: [1]}, {props: [2]}).props
     expect(Array.isArray(res)).toBe(true)
     expect(res.length).toBe(2)
     expect(res[0]).toBe(1)