Skip to content

Commit 4236c53

Browse files
committed
unit tests pass
1 parent 7f7df41 commit 4236c53

File tree

16 files changed

+97
-68
lines changed

16 files changed

+97
-68
lines changed

src/compiler/compile.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@ function compileDirectives (attrs, options) {
570570

571571
// event handlers
572572
if (onRE.test(name)) {
573-
pushDir('on', internalDirectives.on, {
573+
pushDir('on', publicDirectives.on, {
574574
arg: name.replace(onRE, '')
575575
})
576576
} else
@@ -613,6 +613,7 @@ function compileDirectives (attrs, options) {
613613
isLiteral = true
614614
}
615615
pushDir(dirName, dirDef, {
616+
arg: arg,
616617
literal: isLiteral
617618
})
618619
}

src/directive.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -163,6 +163,15 @@ Directive.prototype.param = function (name) {
163163
if (param != null) {
164164
this.el.removeAttribute(name)
165165
param = (this._scope || this.vm).$interpolate(param)
166+
} else {
167+
param = _.getBindAttr(this.el, name)
168+
if (param != null) {
169+
param = (this._scope || this.vm).$eval(param)
170+
process.env.NODE_ENV !== 'production' && _.log(
171+
'You are using bind- syntax on "' + name + '", which ' +
172+
'is a directive param. It will be evaluated only once.'
173+
)
174+
}
166175
}
167176
return param
168177
}

test/unit/specs/compiler/compile_spec.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ if (_.inBrowser) {
5050

5151
it('normal directives', function () {
5252
el.setAttribute('v-a', 'b')
53-
el.innerHTML = '<p v-a="a" v-b="1">hello</p><div v-b#="hi"></div>'
53+
el.innerHTML = '<p v-a:hello="a" v-b="1">hello</p><div v-b#="hi"></div>'
5454
var defA = { priority: 1 }
5555
var defB = { priority: 2 }
5656
var options = _.mergeOptions(Vue.options, {
@@ -80,6 +80,7 @@ if (_.inBrowser) {
8080
expect(args[0].name).toBe('a')
8181
expect(args[0].expression).toBe('a')
8282
expect(args[0].def).toBe(defA)
83+
expect(args[0].arg).toBe('hello')
8384
expect(args[1]).toBe(el.firstChild)
8485
// 3 (expression literal)
8586
args = vm._bindDir.calls.argsFor(isAttrReversed ? 1 : 2)
@@ -141,7 +142,7 @@ if (_.inBrowser) {
141142
expect(args[0].name).toBe('on')
142143
expect(args[0].expression).toBe('a++')
143144
expect(args[0].arg).toBe('click')
144-
expect(args[0].def).toBe(internalDirectives.on)
145+
expect(args[0].def).toBe(publicDirectives.on)
145146
expect(args[1]).toBe(el)
146147
})
147148

@@ -315,13 +316,13 @@ if (_.inBrowser) {
315316
vm = new Vue({
316317
el: el,
317318
template:
318-
'<test class="a" on-click="test(1)"></test>',
319+
'<test class="a" v-on:click="test(1)"></test>',
319320
methods: {
320321
test: parentSpy
321322
},
322323
components: {
323324
test: {
324-
template: '<div class="b" on-click="test(2)"></div>',
325+
template: '<div class="b" v-on:click="test(2)"></div>',
325326
replace: true,
326327
methods: {
327328
test: childSpy

test/unit/specs/directives/element/partial_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ describe('Partial', function () {
3131
it('dynamic', function (done) {
3232
var vm = new Vue({
3333
el: el,
34-
template: '<partial bind-name="\'test-\' + id"></partial>',
34+
template: '<partial :name="\'test-\' + id"></partial>',
3535
data: {
3636
id: 'a'
3737
},
@@ -80,7 +80,7 @@ describe('Partial', function () {
8080
it('teardown', function () {
8181
var vm = new Vue({
8282
el: el,
83-
template: '<partial bind-name="\'test-\' + id"></partial>',
83+
template: '<partial :name="\'test-\' + id"></partial>',
8484
data: {
8585
id: 'a'
8686
},

test/unit/specs/directives/element/slot_spec.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ describe('Slot Distribution', function () {
160160
a: 1,
161161
show: true
162162
},
163-
template: '<test bind-show="show">{{a}}</test>',
163+
template: '<test :show="show">{{a}}</test>',
164164
components: {
165165
test: {
166166
props: ['show'],
@@ -189,7 +189,7 @@ describe('Slot Distribution', function () {
189189
el.innerHTML = '<p slot="1">1</p><p slot="2">2</p><p slot="3">3</p>'
190190
new Vue({
191191
el: el,
192-
template: '<div v-for="n in list"><slot bind-name="$index + 1"></slot></div>',
192+
template: '<div v-for="n in list"><slot :name="$index + 1"></slot></div>',
193193
data: {
194194
list: 0
195195
},
@@ -203,7 +203,7 @@ describe('Slot Distribution', function () {
203203
it('v-for + component + parent directive + transclusion', function (done) {
204204
var vm = new Vue({
205205
el: el,
206-
template: '<test v-for="n in list" bind-class="cls" bind-a="n.a">{{msg}}</test>',
206+
template: '<test v-for="n in list" :class="cls" :a="n.a">{{msg}}</test>',
207207
data: {
208208
cls: 'parent',
209209
msg: 'hi',
@@ -269,7 +269,7 @@ describe('Slot Distribution', function () {
269269
el: el,
270270
template:
271271
'<testa>' +
272-
'<testb v-if="ok" bind-msg="msg"></testb>' +
272+
'<testb v-if="ok" :msg="msg"></testb>' +
273273
'</testa>',
274274
data: {
275275
ok: false,

test/unit/specs/directives/internal/component_spec.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ if (_.inBrowser) {
104104
it('dynamic', function (done) {
105105
var vm = new Vue({
106106
el: el,
107-
template: '<component bind-is="view" bind-view="view"></component>',
107+
template: '<component :is="view" :view="view"></component>',
108108
data: {
109109
view: 'view-a'
110110
},
@@ -142,7 +142,7 @@ if (_.inBrowser) {
142142
var spyB = jasmine.createSpy()
143143
var vm = new Vue({
144144
el: el,
145-
template: '<component bind-is="view" keep-alive></component>',
145+
template: '<component :is="view" keep-alive></component>',
146146
data: {
147147
view: 'view-a'
148148
},
@@ -251,7 +251,7 @@ if (_.inBrowser) {
251251
data: {
252252
list: [{a: 1}, {a: 2}]
253253
},
254-
template: '<test bind-collection="list"></test>',
254+
template: '<test :collection="list"></test>',
255255
components: {
256256
test: {
257257
template: '<ul><li v-for="item in collection">{{item.a}}</li></ul>',
@@ -290,7 +290,7 @@ if (_.inBrowser) {
290290
data: {
291291
view: 'view-a'
292292
},
293-
template: '<component bind-is="view"></component>',
293+
template: '<component :is="view"></component>',
294294
components: {
295295
'view-a': {
296296
template: 'AAA',
@@ -339,7 +339,7 @@ if (_.inBrowser) {
339339
data: {
340340
view: 'view-a'
341341
},
342-
template: '<component bind-is="view" keep-alive></component>',
342+
template: '<component :is="view" keep-alive></component>',
343343
components: {
344344
'view-a': {
345345
template: 'AAA',
@@ -381,7 +381,7 @@ if (_.inBrowser) {
381381
data: {
382382
view: 'view-a'
383383
},
384-
template: '<component bind-is="view" transition="test" transition-mode="in-out"></component>',
384+
template: '<component :is="view" transition="test" transition-mode="in-out"></component>',
385385
components: {
386386
'view-a': { template: 'AAA' },
387387
'view-b': { template: 'BBB' }
@@ -425,7 +425,7 @@ if (_.inBrowser) {
425425
data: {
426426
view: 'view-a'
427427
},
428-
template: '<component bind-is="view" transition="test" transition-mode="out-in"></component>',
428+
template: '<component :is="view" transition="test" transition-mode="out-in"></component>',
429429
components: {
430430
'view-a': { template: 'AAA' },
431431
'view-b': { template: 'BBB' }
@@ -459,7 +459,7 @@ if (_.inBrowser) {
459459
it('teardown', function (done) {
460460
var vm = new Vue({
461461
el: el,
462-
template: '<component bind-is="view" keep-alive></component>',
462+
template: '<component :is="view" keep-alive></component>',
463463
data: {
464464
view: 'test'
465465
},

test/unit/specs/directives/internal/prop_spec.js

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ if (_.inBrowser) {
1616
data: {
1717
b: 'B'
1818
},
19-
template: '<test bind-b="b" $.child></test>',
19+
template: '<test v-bind:b="b" $.child></test>',
2020
components: {
2121
test: {
2222
props: ['b'],
@@ -40,7 +40,7 @@ if (_.inBrowser) {
4040
it('with filters', function (done) {
4141
var vm = new Vue({
4242
el: el,
43-
template: '<test bind-name="a | test"></test>',
43+
template: '<test :name="a | test"></test>',
4444
data: {
4545
a: 123
4646
},
@@ -73,7 +73,7 @@ if (_.inBrowser) {
7373
a: 'A'
7474
}
7575
},
76-
template: '<test bind-testt@="test" bind-bb@="b" bind-a@=" test.a " $.child></test>',
76+
template: '<test v-bind:testt@="test" :bb@="b" :a@=" test.a " $.child></test>',
7777
components: {
7878
test: {
7979
props: ['testt', 'bb', 'a'],
@@ -123,7 +123,7 @@ if (_.inBrowser) {
123123
data: {
124124
b: 'B'
125125
},
126-
template: '<test bind-b*="b" $.child></test>',
126+
template: '<test :b*="b" $.child></test>',
127127
components: {
128128
test: {
129129
props: ['b'],
@@ -145,7 +145,7 @@ if (_.inBrowser) {
145145
data: {
146146
b: 'B'
147147
},
148-
template: '<test bind-b@=" b + \'B\'" $.child></test>',
148+
template: '<test :b@=" b + \'B\'" $.child></test>',
149149
components: {
150150
test: {
151151
props: ['b'],
@@ -170,7 +170,7 @@ if (_.inBrowser) {
170170
it('warn expect two-way', function () {
171171
new Vue({
172172
el: el,
173-
template: '<test bind-test="ok"></test>',
173+
template: '<test :test="ok"></test>',
174174
data: {
175175
ok: 'hi'
176176
},
@@ -190,7 +190,7 @@ if (_.inBrowser) {
190190
it('warn $data as prop', function () {
191191
new Vue({
192192
el: el,
193-
template: '<test bind-$data="ok"></test>',
193+
template: '<test></test>',
194194
data: {
195195
ok: 'hi'
196196
},
@@ -206,7 +206,7 @@ if (_.inBrowser) {
206206
it('warn invalid keys', function () {
207207
new Vue({
208208
el: el,
209-
template: '<test bind-a.b.c="test"></test>',
209+
template: '<test :a.b.c="test"></test>',
210210
components: {
211211
test: {
212212
props: ['a.b.c']
@@ -248,7 +248,7 @@ if (_.inBrowser) {
248248
a: 'A',
249249
b: 'B'
250250
},
251-
template: '<test bind-aa@="a" bind-bb="b"></test>',
251+
template: '<test :aa@="a" :bb="b"></test>',
252252
components: {
253253
test: {
254254
props: ['aa', 'bb'],
@@ -279,7 +279,7 @@ if (_.inBrowser) {
279279
it('block instance with replace:true', function () {
280280
new Vue({
281281
el: el,
282-
template: '<test bind-b="a" bind-c="d"></test>',
282+
template: '<test :b="a" :c="d"></test>',
283283
data: {
284284
a: 'AAA',
285285
d: 'DDD'
@@ -300,7 +300,7 @@ if (_.inBrowser) {
300300
function makeInstance (value, type, validator) {
301301
return new Vue({
302302
el: document.createElement('div'),
303-
template: '<test bind-test="val"></test>',
303+
template: '<test :test="val"></test>',
304304
data: {
305305
val: value
306306
},
@@ -417,7 +417,7 @@ if (_.inBrowser) {
417417
it('alternative syntax', function () {
418418
new Vue({
419419
el: el,
420-
template: '<test bind-b="a" bind-c="d"></test>',
420+
template: '<test :b="a" :c="d"></test>',
421421
data: {
422422
a: 'AAA',
423423
d: 'DDD'

test/unit/specs/directives/internal/ref_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ if (_.inBrowser) {
3939
el: el,
4040
components: components,
4141
data: { test: 'test' },
42-
template: '<component bind-is="test" $.test></component>'
42+
template: '<component :is="test" $.test></component>'
4343
})
4444
expect(vm.$.test.$options.id).toBe('test')
4545
vm.test = 'test2'
@@ -57,7 +57,7 @@ if (_.inBrowser) {
5757
var vm = new Vue({
5858
el: el,
5959
data: { view: 'one' },
60-
template: '{{$.test.value}}<component bind-is="view" $.test></component>',
60+
template: '{{$.test.value}}<component :is="view" $.test></component>',
6161
components: {
6262
one: {
6363
id: 'one',

test/unit/specs/directives/internal/transition_spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ if (_.inBrowser) {
5959
}
6060
var vm = new Vue({
6161
el: el,
62-
template: '<div v-show="show" bind-transition="trans"></div>',
62+
template: '<div v-show="show" :transition="trans"></div>',
6363
data: {
6464
show: true,
6565
trans: 'a'

test/unit/specs/directives/public/for/for_ref_spec.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('v-for + ref', function () {
1212
var vm = new Vue({
1313
el: el,
1414
data: { items: [1, 2, 3, 4, 5] },
15-
template: '<test v-for="item in items" bind-item="item" $.test></test>',
15+
template: '<test v-for="item in items" :item="item" $.test></test>',
1616
components: {
1717
test: {
1818
props: ['item']
@@ -41,7 +41,7 @@ describe('v-for + ref', function () {
4141
b: 2
4242
}
4343
},
44-
template: '<test v-for="item in items" bind-item="item" $.test></test>',
44+
template: '<test v-for="item in items" :item="item" $.test></test>',
4545
components: {
4646
test: {
4747
props: ['item']

0 commit comments

Comments
 (0)