Skip to content

Commit 56419ff

Browse files
committed
Add positional info to wrappers
1 parent 6e18cfe commit 56419ff

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,13 +43,13 @@ function toEstree(tree, options) {
4343

4444
if (result) {
4545
if (result.type !== 'JSXFragment' && result.type !== 'JSXElement') {
46-
result = createJsxFragment(null, [result])
46+
result = createJsxFragment(tree, [result])
4747
}
4848

49-
body.push(create(null, {type: 'ExpressionStatement', expression: result}))
49+
body.push(create(tree, {type: 'ExpressionStatement', expression: result}))
5050
}
5151

52-
return create(null, {type: 'Program', body: body, sourceType: 'module'})
52+
return create(tree, {type: 'Program', body: body, sourceType: 'module'})
5353
}
5454

5555
function invalid(value) {

test.js

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,18 @@ test('hast-util-to-estree', function (t) {
9191
end: 4,
9292
loc: {start: {line: 1, column: 0}, end: {line: 1, column: 4}},
9393
range: [0, 4]
94-
}
94+
},
95+
start: 0,
96+
end: 4,
97+
loc: {start: {line: 1, column: 0}, end: {line: 1, column: 4}},
98+
range: [0, 4]
9599
}
96100
],
97-
sourceType: 'module'
101+
sourceType: 'module',
102+
start: 0,
103+
end: 4,
104+
loc: {start: {line: 1, column: 0}, end: {line: 1, column: 4}},
105+
range: [0, 4]
98106
},
99107
'should support position info when defined'
100108
)

0 commit comments

Comments
 (0)