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) {
89
89
}
90
90
}
91
91
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
+
92
100
// beforeCompile hook
93
101
compiler . execHook ( 'created' )
94
102
Original file line number Diff line number Diff line change 1
1
var utils = require ( '../utils' ) ,
2
2
config = require ( '../config' ) ,
3
- transition = require ( '../transition' ) ,
4
- NumberRE = / ^ [ \d \. ] + $ / ,
5
- CommaRE = / \\ , / g
3
+ transition = require ( '../transition' )
6
4
7
5
module . exports = {
8
6
@@ -56,18 +54,6 @@ module.exports = {
56
54
el . removeAttribute ( config . prefix + '-cloak' )
57
55
} )
58
56
}
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
- }
71
57
}
72
58
73
59
}
Original file line number Diff line number Diff line change @@ -602,6 +602,23 @@ describe('UNIT: API', function () {
602
602
603
603
} )
604
604
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
+
605
622
describe ( 'directives' , function ( ) {
606
623
607
624
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 () {
844
844
845
845
} )
846
846
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
-
862
847
} )
863
848
864
849
function mockDirective ( dirName , tag , type ) {
You can’t perform that action at this time.
0 commit comments