File tree Expand file tree Collapse file tree 4 files changed +26
-30
lines changed
Expand file tree Collapse file tree 4 files changed +26
-30
lines changed Original file line number Diff line number Diff line change @@ -89,6 +89,14 @@ function Compiler (vm, options) {
8989 }
9090 }
9191
92+ // copy paramAttributes
93+ if ( options . paramAttributes ) {
94+ options . paramAttributes . forEach ( function ( attr ) {
95+ var val = el . getAttribute ( attr )
96+ vm [ attr ] = isNaN ( val ) ? val : Number ( val )
97+ } )
98+ }
99+
92100 // beforeCompile hook
93101 compiler . execHook ( 'created' )
94102
Original file line number Diff line number Diff line change 11var utils = require ( '../utils' ) ,
22 config = require ( '../config' ) ,
3- transition = require ( '../transition' ) ,
4- NumberRE = / ^ [ \d \. ] + $ / ,
5- CommaRE = / \\ , / g
3+ transition = require ( '../transition' )
64
75module . exports = {
86
@@ -56,18 +54,6 @@ module.exports = {
5654 el . removeAttribute ( config . prefix + '-cloak' )
5755 } )
5856 }
59- } ,
60-
61- data : {
62- bind : function ( ) {
63- var val = this . key
64- this . vm . $set (
65- this . arg ,
66- NumberRE . test ( val )
67- ? + val
68- : val . replace ( CommaRE , ',' )
69- )
70- }
7157 }
7258
7359}
Original file line number Diff line number Diff line change @@ -602,6 +602,23 @@ describe('UNIT: API', function () {
602602
603603 } )
604604
605+ describe ( 'paramAttributes' , function ( ) {
606+
607+ it ( 'should copy listed attributes into data and parse Numbers' , function ( ) {
608+ var Test = Vue . extend ( {
609+ template : '<div a="1" b="hello"></div>' ,
610+ replace : true ,
611+ paramAttributes : [ 'a' , 'b' ]
612+ } )
613+ var v = new Test ( )
614+ assert . strictEqual ( v . a , 1 )
615+ assert . strictEqual ( v . $data . a , 1 )
616+ assert . strictEqual ( v . b , 'hello' )
617+ assert . strictEqual ( v . $data . b , 'hello' )
618+ } )
619+
620+ } )
621+
605622 describe ( 'directives' , function ( ) {
606623
607624 it ( 'should allow the VM to use private directives' , function ( done ) {
Original file line number Diff line number Diff line change @@ -844,21 +844,6 @@ describe('UNIT: Directives', function () {
844844
845845 } )
846846
847- describe ( 'data' , function ( ) {
848-
849- it ( 'should set data on the child VM' , function ( ) {
850- var v = new Vue ( {
851- template : '<div v-component="test" v-ref="test" v-data="a:1,b:hi"></div>' ,
852- components : {
853- test : Vue
854- }
855- } )
856- assert . strictEqual ( v . $ . test . a , 1 )
857- assert . strictEqual ( v . $ . test . b , 'hi' )
858- } )
859-
860- } )
861-
862847} )
863848
864849function mockDirective ( dirName , tag , type ) {
You can’t perform that action at this time.
0 commit comments