MCPcopy Create free account
hub / github.com/TruthHun/BookStack / initProps

Function initProps

static/vuejs/vue.runtime.js:2673–2715  ·  view source on GitHub ↗
(vm, propsOptions)

Source from the content-addressed store, hash-verified

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

Callers 1

initStateFunction · 0.70

Calls 1

loopFunction · 0.70

Tested by

no test coverage detected