(vm, propsOptions)
| 4642 | } |
| 4643 | |
| 4644 | function initProps (vm, propsOptions) { |
| 4645 | var propsData = vm.$options.propsData || {}; |
| 4646 | var props = vm._props = {}; |
| 4647 | // cache prop keys so that future props updates can iterate using Array |
| 4648 | // instead of dynamic object key enumeration. |
| 4649 | var keys = vm.$options._propKeys = []; |
| 4650 | var isRoot = !vm.$parent; |
| 4651 | // root instance props should be converted |
| 4652 | if (!isRoot) { |
| 4653 | toggleObserving(false); |
| 4654 | } |
| 4655 | var loop = function ( key ) { |
| 4656 | keys.push(key); |
| 4657 | var value = validateProp(key, propsOptions, propsData, vm); |
| 4658 | /* istanbul ignore else */ |
| 4659 | { |
| 4660 | var hyphenatedKey = hyphenate(key); |
| 4661 | if (isReservedAttribute(hyphenatedKey) || |
| 4662 | config.isReservedAttr(hyphenatedKey)) { |
| 4663 | warn( |
| 4664 | ("\"" + hyphenatedKey + "\" is a reserved attribute and cannot be used as component prop."), |
| 4665 | vm |
| 4666 | ); |
| 4667 | } |
| 4668 | defineReactive$$1(props, key, value, function () { |
| 4669 | if (!isRoot && !isUpdatingChildComponent) { |
| 4670 | warn( |
| 4671 | "Avoid mutating a prop directly since the value will be " + |
| 4672 | "overwritten whenever the parent component re-renders. " + |
| 4673 | "Instead, use a data or computed property based on the prop's " + |
| 4674 | "value. Prop being mutated: \"" + key + "\"", |
| 4675 | vm |
| 4676 | ); |
| 4677 | } |
| 4678 | }); |
| 4679 | } |
| 4680 | // static props are already proxied on the component's prototype |
| 4681 | // during Vue.extend(). We only need to proxy props defined at |
| 4682 | // instantiation here. |
| 4683 | if (!(key in vm)) { |
| 4684 | proxy(vm, "_props", key); |
| 4685 | } |
| 4686 | }; |
| 4687 | |
| 4688 | for (var key in propsOptions) loop( key ); |
| 4689 | toggleObserving(true); |
| 4690 | } |
| 4691 | |
| 4692 | function initData (vm) { |
| 4693 | var data = vm.$options.data; |
no test coverage detected