Explorar el Código

use new modifier syntax

Evan You hace 10 años
padre
commit
b36397b0de

+ 2 - 2
src/compiler/compile-props.js

@@ -57,9 +57,9 @@ module.exports = function compileProps (el, propOptions) {
 
       // then check dynamic version
       if ((value = _.getBindAttr(el, attr)) === null) {
-        if ((value = _.getBindAttr(el, attr + '&')) !== null) {
+        if ((value = _.getBindAttr(el, attr + '.sync')) !== null) {
           prop.mode = propBindingModes.TWO_WAY
-        } else if ((value = _.getBindAttr(el, attr + '*')) !== null) {
+        } else if ((value = _.getBindAttr(el, attr + '.once')) !== null) {
           prop.mode = propBindingModes.ONE_TIME
         }
       }

+ 1 - 1
src/compiler/compile.js

@@ -10,7 +10,7 @@ var resolveAsset = _.resolveAsset
 // special binding prefixes
 var bindRE = /^v-bind:|^:/
 var onRE = /^v-on:|^@/
-var literalRE = /#$/
+var literalRE = /\.literal$/
 var argRE = /:(.*)$/
 var transitionRE = /^(v-bind:|:)?transition$/
 

+ 1 - 1
src/compiler/transclude.js

@@ -1,6 +1,6 @@
 var _ = require('../util')
 var templateParser = require('../parsers/template')
-var specialCharRE = /[#@\*\$\.]/
+var specialCharRE = /[^a-zA-Z_\-:\.]/
 
 /**
  * Process an element or a DocumentFragment based on a

+ 1 - 1
src/directives/public/on.js

@@ -41,7 +41,7 @@ module.exports = {
   bind: function () {
     // 1.0.0 key filter
     var rawEvent = this.event = this.arg
-    var keyIndex = rawEvent.indexOf(':')
+    var keyIndex = rawEvent.indexOf('.')
     if (keyIndex > -1) {
       this.event = rawEvent.slice(0, keyIndex)
       this.key = rawEvent.slice(keyIndex + 1)

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

@@ -50,7 +50,7 @@ if (_.inBrowser) {
 
     it('normal directives', function () {
       el.setAttribute('v-a', 'b')
-      el.innerHTML = '<p v-a:hello="a" v-b="1">hello</p><div v-b#="hi"></div>'
+      el.innerHTML = '<p v-a:hello="a" v-b="1">hello</p><div v-b.literal="hi"></div>'
       var defA = { priority: 1 }
       var defB = { priority: 2 }
       var options = _.mergeOptions(Vue.options, {
@@ -230,9 +230,9 @@ if (_.inBrowser) {
         'v-bind:test-normal="a" ' +
         'test-literal="1" ' +
         ':optimize-literal="1" ' +
-        ':test-two-way&="a" ' +
-        ':two-way-warn&="a + 1" ' +
-        ':test-one-time*="a"></div>'
+        ':test-two-way.sync="a" ' +
+        ':two-way-warn.sync="a + 1" ' +
+        ':test-one-time.once="a"></div>'
       compiler.compileAndLinkProps(vm, el.firstChild, props)
       expect(vm._bindDir.calls.count()).toBe(3) // skip literal and one time
       // literal

+ 4 - 4
test/unit/specs/directives/internal/prop_spec.js

@@ -73,7 +73,7 @@ if (_.inBrowser) {
             a: 'A'
           }
         },
-        template: '<test v-bind:testt&="test" :bb&="b" :a&=" test.a " v-ref:child></test>',
+        template: '<test v-bind:testt.sync="test" :bb.sync="b" :a.sync=" test.a " v-ref:child></test>',
         components: {
           test: {
             props: ['testt', 'bb', 'a'],
@@ -123,7 +123,7 @@ if (_.inBrowser) {
         data: {
           b: 'B'
         },
-        template: '<test :b*="b" v-ref:child></test>',
+        template: '<test :b.once="b" v-ref:child></test>',
         components: {
           test: {
             props: ['b'],
@@ -145,7 +145,7 @@ if (_.inBrowser) {
         data: {
           b: 'B'
         },
-        template: '<test :b&=" b + \'B\'" v-ref:child></test>',
+        template: '<test :b.sync=" b + \'B\'" v-ref:child></test>',
         components: {
           test: {
             props: ['b'],
@@ -248,7 +248,7 @@ if (_.inBrowser) {
           a: 'A',
           b: 'B'
         },
-        template: '<test :aa&="a" :bb="b"></test>',
+        template: '<test :aa.sync="a" :bb="b"></test>',
         components: {
           test: {
             props: ['aa', 'bb'],

+ 2 - 2
test/unit/specs/directives/public/on_spec.js

@@ -71,7 +71,7 @@ if (_.inBrowser) {
     it('with key filter', function (done) {
       new Vue({
         el: el,
-        template: '<a v-on:keyup:enter="test">{{a}}</a>',
+        template: '<a v-on:keyup.enter="test">{{a}}</a>',
         data: {a: 1},
         methods: {
           test: function () {
@@ -92,7 +92,7 @@ if (_.inBrowser) {
     it('with key filter (keycode)', function (done) {
       new Vue({
         el: el,
-        template: '<a v-on:keyup:13="test">{{a}}</a>',
+        template: '<a v-on:keyup.13="test">{{a}}</a>',
         data: {a: 1},
         methods: {
           test: function () {