* Ensure all props option syntax are normalized into the * Object-based format.
(options, vm)
| 1416 | * Object-based format. |
| 1417 | */ |
| 1418 | function normalizeProps (options, vm) { |
| 1419 | var props = options.props; |
| 1420 | if (!props) { return } |
| 1421 | var res = {}; |
| 1422 | var i, val, name; |
| 1423 | if (Array.isArray(props)) { |
| 1424 | i = props.length; |
| 1425 | while (i--) { |
| 1426 | val = props[i]; |
| 1427 | if (typeof val === 'string') { |
| 1428 | name = camelize(val); |
| 1429 | res[name] = { type: null }; |
| 1430 | } else if (process.env.NODE_ENV !== 'production') { |
| 1431 | warn('props must be strings when using array syntax.'); |
| 1432 | } |
| 1433 | } |
| 1434 | } else if (isPlainObject(props)) { |
| 1435 | for (var key in props) { |
| 1436 | val = props[key]; |
| 1437 | name = camelize(key); |
| 1438 | res[name] = isPlainObject(val) |
| 1439 | ? val |
| 1440 | : { type: val }; |
| 1441 | } |
| 1442 | } else if (process.env.NODE_ENV !== 'production') { |
| 1443 | warn( |
| 1444 | "Invalid value for option \"props\": expected an Array or an Object, " + |
| 1445 | "but got " + (toRawType(props)) + ".", |
| 1446 | vm |
| 1447 | ); |
| 1448 | } |
| 1449 | options.props = res; |
| 1450 | } |
| 1451 | |
| 1452 | /** |
| 1453 | * Normalize all injections into Object-based format |
no test coverage detected