| 2675 | var isReservedProp = { key: 1, ref: 1, slot: 1 }; |
| 2676 | |
| 2677 | function initProps (vm, propsOptions) { |
| 2678 | var propsData = vm.$options.propsData || {}; |
| 2679 | var props = vm._props = {}; |
| 2680 | // cache prop keys so that future props updates can iterate using Array |
| 2681 | // instead of dynamic object key enumeration. |
| 2682 | var keys = vm.$options._propKeys = []; |
| 2683 | var isRoot = !vm.$parent; |
| 2684 | // root instance props should be converted |
| 2685 | observerState.shouldConvert = isRoot; |
| 2686 | var loop = function ( key ) { |
| 2687 | keys.push(key); |
| 2688 | var value = validateProp(key, propsOptions, propsData, vm); |
| 2689 | /* istanbul ignore else */ |
| 2690 | { |
| 2691 | if (isReservedProp[key]) { |
| 2692 | warn( |
| 2693 | ("\"" + key + "\" is a reserved attribute and cannot be used as component prop."), |
| 2694 | vm |
| 2695 | ); |
| 2696 | } |
| 2697 | defineReactive$$1(props, key, value, function () { |
| 2698 | if (vm.$parent && !observerState.isSettingProps) { |
| 2699 | warn( |
| 2700 | "Avoid mutating a prop directly since the value will be " + |
| 2701 | "overwritten whenever the parent component re-renders. " + |
| 2702 | "Instead, use a data or computed property based on the prop's " + |
| 2703 | "value. Prop being mutated: \"" + key + "\"", |
| 2704 | vm |
| 2705 | ); |
| 2706 | } |
| 2707 | }); |
| 2708 | } |
| 2709 | // static props are already proxied on the component's prototype |
| 2710 | // during Vue.extend(). We only need to proxy props defined at |
| 2711 | // instantiation here. |
| 2712 | if (!(key in vm)) { |
| 2713 | proxy(vm, "_props", key); |
| 2714 | } |
| 2715 | }; |
| 2716 | |
| 2717 | for (var key in propsOptions) loop( key ); |
| 2718 | observerState.shouldConvert = true; |
| 2719 | } |
| 2720 | |
| 2721 | function initData (vm) { |
| 2722 | var data = vm.$options.data; |