Skip to content

Commit db82b0f

Browse files
author
Evan You
committed
#136 default value fix for paramAttributes
1 parent 15c3c8b commit db82b0f

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

src/compiler.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,9 @@ function Compiler (vm, options) {
9494
if (options.paramAttributes) {
9595
options.paramAttributes.forEach(function (attr) {
9696
var val = el.getAttribute(attr)
97-
vm[attr] = isNaN(val) ? val : Number(val)
97+
vm[attr] = (isNaN(val) || val === null)
98+
? val
99+
: Number(val)
98100
})
99101
}
100102

test/unit/specs/api.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -608,13 +608,15 @@ describe('UNIT: API', function () {
608608
var Test = Vue.extend({
609609
template: '<div a="1" b="hello"></div>',
610610
replace: true,
611-
paramAttributes: ['a', 'b']
611+
paramAttributes: ['a', 'b', 'c']
612612
})
613613
var v = new Test()
614614
assert.strictEqual(v.a, 1)
615615
assert.strictEqual(v.$data.a, 1)
616616
assert.strictEqual(v.b, 'hello')
617617
assert.strictEqual(v.$data.b, 'hello')
618+
assert.strictEqual(v.c, null)
619+
assert.strictEqual(v.$data.c, null)
618620
})
619621

620622
})

0 commit comments

Comments
 (0)