forked from rollup/rollup
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathJSXSpreadAttribute.ts
More file actions
20 lines (18 loc) · 805 Bytes
/
JSXSpreadAttribute.ts
File metadata and controls
20 lines (18 loc) · 805 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
import type MagicString from 'magic-string';
import type { NormalizedJsxOptions } from '../../rollup/types';
import type { RenderOptions } from '../../utils/renderHelpers';
import type * as NodeType from './NodeType';
import type { ExpressionNode } from './shared/Node';
import { NodeBase } from './shared/Node';
export default class JSXSpreadAttribute extends NodeBase {
type!: NodeType.tJSXSpreadAttribute;
argument!: ExpressionNode;
render(code: MagicString, options: RenderOptions): void {
this.argument.render(code, options);
const { mode } = this.scope.context.options.jsx as NormalizedJsxOptions;
if (mode !== 'preserve') {
code.overwrite(this.start, this.argument.start, '', { contentOnly: true });
code.overwrite(this.argument.end, this.end, '', { contentOnly: true });
}
}
}