* Normalize all injections into Object-based format
(options, vm)
| 1466 | * Normalize all injections into Object-based format |
| 1467 | */ |
| 1468 | function normalizeInject (options, vm) { |
| 1469 | var inject = options.inject; |
| 1470 | if (!inject) { return } |
| 1471 | var normalized = options.inject = {}; |
| 1472 | if (Array.isArray(inject)) { |
| 1473 | for (var i = 0; i < inject.length; i++) { |
| 1474 | normalized[inject[i]] = { from: inject[i] }; |
| 1475 | } |
| 1476 | } else if (isPlainObject(inject)) { |
| 1477 | for (var key in inject) { |
| 1478 | var val = inject[key]; |
| 1479 | normalized[key] = isPlainObject(val) |
| 1480 | ? extend({ from: key }, val) |
| 1481 | : { from: val }; |
| 1482 | } |
| 1483 | } else { |
| 1484 | warn( |
| 1485 | "Invalid value for option \"inject\": expected an Array or an Object, " + |
| 1486 | "but got " + (toRawType(inject)) + ".", |
| 1487 | vm |
| 1488 | ); |
| 1489 | } |
| 1490 | } |
| 1491 | |
| 1492 | /** |
| 1493 | * Normalize raw function directives into object format. |
no test coverage detected