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

Function validateProp

static/vuejs/vue.runtime.common.js:1268–1299  ·  view source on GitHub ↗
(
  key,
  propOptions,
  propsData,
  vm
)

Source from the content-addressed store, hash-verified

1266/* */
1267
1268function validateProp (
1269 key,
1270 propOptions,
1271 propsData,
1272 vm
1273) {
1274 var prop = propOptions[key];
1275 var absent = !hasOwn(propsData, key);
1276 var value = propsData[key];
1277 // handle boolean props
1278 if (isType(Boolean, prop.type)) {
1279 if (absent && !hasOwn(prop, 'default')) {
1280 value = false;
1281 } else if (!isType(String, prop.type) && (value === '' || value === hyphenate(key))) {
1282 value = true;
1283 }
1284 }
1285 // check default value
1286 if (value === undefined) {
1287 value = getPropDefaultValue(vm, prop, key);
1288 // since the default value is a fresh copy,
1289 // make sure to observe it.
1290 var prevShouldConvert = observerState.shouldConvert;
1291 observerState.shouldConvert = true;
1292 observe(value);
1293 observerState.shouldConvert = prevShouldConvert;
1294 }
1295 if (process.env.NODE_ENV !== 'production') {
1296 assertProp(prop, key, value, vm, absent);
1297 }
1298 return value
1299}
1300
1301/**
1302 * Get the default value of a prop.

Callers 3

updateChildComponentFunction · 0.70
loopFunction · 0.70

Calls 6

hasOwnFunction · 0.70
isTypeFunction · 0.70
getPropDefaultValueFunction · 0.70
observeFunction · 0.70
assertPropFunction · 0.70
hyphenateFunction · 0.50

Tested by

no test coverage detected