Open
Description
Version
2.6.12
Steps to reproduce
<div></div>
<script>
new Vue({
el: 'main',
template: '<MyDatetime :value="datetime" />',
data: {
datetime: Date.now(),
},
components: {
MyDatetime: {
template: `
<div>
expect undefined: {{ toString + "" }}<br />
expect default: {{ toLocalString + "" }}<br />
</div>`,
props: {
value: {
type: Number,
},
toString: {
validator: mode => [ 'date-time', 'date', 'time' ].includes(mode),
},
toLocalString: {
validator: mode => [ 'date-time', 'date', 'time', 'default' ].includes(mode),
default: 'default',
},
},
},
},
});
</script>
What is expected?
They are all keys match the uni simple rule: not start with _
or $
What is actually happening?
If parent component doesn't pass the prop, then the component will get neither undefined
nor default
, but the value in Object.prototype
.
{}
in these two lines need to be replaced toObject.create(null)
, the first line is required for two cases, and the second line is required fordefault
case,
vue/src/core/instance/state.js
Line 66 in 33e669b
- there still leave
constructor
which can't be used, it needdelete Vue.prototype.constructor
, and give an alternative way to do whatvm.constructor
(Sub.prototype.constructor = Sub
) do in current source code.