* Ensure all props option syntax are normalized into the * Object-based format.
(options)
| 1140 | * Object-based format. |
| 1141 | */ |
| 1142 | function normalizeProps (options) { |
| 1143 | var props = options.props; |
| 1144 | if (!props) { return } |
| 1145 | var res = {}; |
| 1146 | var i, val, name; |
| 1147 | if (Array.isArray(props)) { |
| 1148 | i = props.length; |
| 1149 | while (i--) { |
| 1150 | val = props[i]; |
| 1151 | if (typeof val === 'string') { |
| 1152 | name = camelize(val); |
| 1153 | res[name] = { type: null }; |
| 1154 | } else if (process.env.NODE_ENV !== 'production') { |
| 1155 | warn('props must be strings when using array syntax.'); |
| 1156 | } |
| 1157 | } |
| 1158 | } else if (isPlainObject(props)) { |
| 1159 | for (var key in props) { |
| 1160 | val = props[key]; |
| 1161 | name = camelize(key); |
| 1162 | res[name] = isPlainObject(val) |
| 1163 | ? val |
| 1164 | : { type: val }; |
| 1165 | } |
| 1166 | } |
| 1167 | options.props = res; |
| 1168 | } |
| 1169 | |
| 1170 | /** |
| 1171 | * Normalize raw function directives into object format. |
no test coverage detected