feat(experimental): support ref transform for sfc normal <script>
This commit is contained in:
@@ -136,6 +136,9 @@ exports[`nested scopes 1`] = `
|
||||
b.value++ // outer b
|
||||
c++ // outer c
|
||||
|
||||
let bar = _ref(0)
|
||||
bar.value++ // outer bar
|
||||
|
||||
function foo({ a }) {
|
||||
a++ // inner a
|
||||
b.value++ // inner b
|
||||
@@ -143,10 +146,11 @@ exports[`nested scopes 1`] = `
|
||||
c.value++ // inner c
|
||||
let d = _ref(0)
|
||||
|
||||
const bar = (c) => {
|
||||
function bar(c) {
|
||||
c++ // nested c
|
||||
d.value++ // nested d
|
||||
}
|
||||
bar() // inner bar
|
||||
|
||||
if (true) {
|
||||
let a = _ref(0)
|
||||
|
||||
@@ -279,6 +279,9 @@ test('nested scopes', () => {
|
||||
b++ // outer b
|
||||
c++ // outer c
|
||||
|
||||
let bar = $ref(0)
|
||||
bar++ // outer bar
|
||||
|
||||
function foo({ a }) {
|
||||
a++ // inner a
|
||||
b++ // inner b
|
||||
@@ -286,10 +289,11 @@ test('nested scopes', () => {
|
||||
c++ // inner c
|
||||
let d = $ref(0)
|
||||
|
||||
const bar = (c) => {
|
||||
function bar(c) {
|
||||
c++ // nested c
|
||||
d++ // nested d
|
||||
}
|
||||
bar() // inner bar
|
||||
|
||||
if (true) {
|
||||
let a = $ref(0)
|
||||
@@ -299,7 +303,7 @@ test('nested scopes', () => {
|
||||
return $$({ a, b, c, d })
|
||||
}
|
||||
`)
|
||||
expect(rootVars).toStrictEqual(['a', 'b'])
|
||||
expect(rootVars).toStrictEqual(['a', 'b', 'bar'])
|
||||
|
||||
expect(code).toMatch('a.value++ // outer a')
|
||||
expect(code).toMatch('b.value++ // outer b')
|
||||
@@ -314,6 +318,10 @@ test('nested scopes', () => {
|
||||
|
||||
expect(code).toMatch(`a.value++ // if block a`) // if block
|
||||
|
||||
expect(code).toMatch(`bar.value++ // outer bar`)
|
||||
// inner bar shadowed by function declaration
|
||||
expect(code).toMatch(`bar() // inner bar`)
|
||||
|
||||
expect(code).toMatch(`return ({ a, b, c, d })`)
|
||||
assertCode(code)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user