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

Function validateProp

static/vuejs/vue.esm.js:1270–1301  ·  view source on GitHub ↗
(
  key,
  propOptions,
  propsData,
  vm
)

Source from the content-addressed store, hash-verified

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