| 898 | } |
| 899 | |
| 900 | function genObjectExpression(node: ObjectExpression, context: CodegenContext) { |
| 901 | const { push, indent, deindent, newline } = context |
| 902 | const { properties } = node |
| 903 | if (!properties.length) { |
| 904 | push(`{}`, NewlineType.None, node) |
| 905 | return |
| 906 | } |
| 907 | const multilines = |
| 908 | properties.length > 1 || |
| 909 | ((!__BROWSER__ || __DEV__) && |
| 910 | properties.some(p => p.value.type !== NodeTypes.SIMPLE_EXPRESSION)) |
| 911 | push(multilines ? `{` : `{ `) |
| 912 | multilines && indent() |
| 913 | for (let i = 0; i < properties.length; i++) { |
| 914 | const { key, value } = properties[i] |
| 915 | class="cm">// key |
| 916 | genExpressionAsPropertyKey(key, context) |
| 917 | push(`: `) |
| 918 | class="cm">// value |
| 919 | genNode(value, context) |
| 920 | if (i < properties.length - 1) { |
| 921 | class="cm">// will only reach this if it's multilines |
| 922 | push(`,`) |
| 923 | newline() |
| 924 | } |
| 925 | } |
| 926 | multilines && deindent() |
| 927 | push(multilines ? `}` : ` }`) |
| 928 | } |
| 929 | |
| 930 | function genArrayExpression(node: ArrayExpression, context: CodegenContext) { |
| 931 | genNodeListAsArray(node.elements as CodegenNode[], context) |