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

Function validateProp

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

Source from the content-addressed store, hash-verified

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