Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Support multiple static blocks (#12738)
- Loading branch information
Showing
35 changed files
with
231 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
3 changes: 0 additions & 3 deletions
3
...valid-duplicated-static-block/output.json → ...c-block/multiple-static-block/output.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...plugin-proposal-class-static-block/test/fixtures/class-static-block/class-binding/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
class Foo { | ||
static bar = 42; | ||
static { | ||
this.foo = Foo.bar; | ||
} | ||
static bar = 42; | ||
} | ||
expect(Foo.foo).toBe(42); |
7 changes: 7 additions & 0 deletions
7
...lugin-proposal-class-static-block/test/fixtures/class-static-block/class-binding/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
class Foo { | ||
static bar = 42; | ||
static { | ||
this.foo = Foo.bar; | ||
} | ||
} | ||
expect(Foo.foo).toBe(42); |
8 changes: 8 additions & 0 deletions
8
...ugin-proposal-class-static-block/test/fixtures/class-static-block/class-binding/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Foo { | ||
static bar = 42; | ||
static #_ = (() => { | ||
this.foo = Foo.bar; | ||
})(); | ||
} | ||
|
||
expect(Foo.foo).toBe(42); |
2 changes: 1 addition & 1 deletion
2
...in-proposal-class-static-block/test/fixtures/class-static-block/class-declaration/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
class Foo { | ||
static bar = 42; | ||
static { | ||
this.foo = this.bar; | ||
} | ||
static bar = 42; | ||
} | ||
expect(Foo.foo).toBe(42); |
2 changes: 1 addition & 1 deletion
2
...n-proposal-class-static-block/test/fixtures/class-static-block/class-declaration/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
class Foo { | ||
static bar = 42; | ||
static { | ||
this.foo = this.bar; | ||
} | ||
static bar = 42; | ||
} | ||
expect(Foo.foo).toBe(42); |
10 changes: 8 additions & 2 deletions
10
...-class-static-block/test/fixtures/class-static-block/multiple-static-initializers/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
class Foo { | ||
static #bar = 21; | ||
static { | ||
this.foo = this.#bar + this.qux; | ||
this.foo = this.#bar; | ||
this.qux1 = this.qux; | ||
} | ||
static qux = 21; | ||
static { | ||
this.qux2 = this.qux; | ||
} | ||
} | ||
expect(Foo.foo).toBe(42); | ||
expect(Foo.foo).toBe(21); | ||
expect(Foo.qux1).toBe(undefined); | ||
expect(Foo.qux2).toBe(21); |
11 changes: 11 additions & 0 deletions
11
...class-static-block/test/fixtures/class-static-block/multiple-static-initializers/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Foo { | ||
static #bar = 21; | ||
static { | ||
this.foo = this.#bar; | ||
this.qux1 = this.qux; | ||
} | ||
static qux = 21; | ||
static { | ||
this.qux2 = this.qux; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
...lass-static-block/test/fixtures/class-static-block/multiple-static-initializers/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Foo { | ||
static #bar = 21; | ||
static #_ = (() => { | ||
this.foo = this.#bar; | ||
this.qux1 = this.qux; | ||
})(); | ||
static qux = 21; | ||
static #_2 = (() => { | ||
this.qux2 = this.qux; | ||
})(); | ||
} |
10 changes: 10 additions & 0 deletions
10
...el-plugin-proposal-class-static-block/test/fixtures/class-static-block/new-target/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Base { | ||
constructor() { | ||
this.Foo = class { | ||
static { | ||
this.foo = new.target; | ||
} | ||
} | ||
} | ||
} | ||
expect((new Base).Foo.foo).toBe(undefined); |
10 changes: 10 additions & 0 deletions
10
...l-plugin-proposal-class-static-block/test/fixtures/class-static-block/new-target/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Base { | ||
constructor() { | ||
this.Foo = class { | ||
static { | ||
this.foo = new.target; | ||
} | ||
} | ||
} | ||
} | ||
expect((new Base).Foo.foo).toBe(undefined); |
12 changes: 12 additions & 0 deletions
12
...-plugin-proposal-class-static-block/test/fixtures/class-static-block/new-target/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class Base { | ||
constructor() { | ||
this.Foo = class { | ||
static #_ = (() => { | ||
this.foo = new.target; | ||
})(); | ||
}; | ||
} | ||
|
||
} | ||
|
||
expect(new Base().Foo.foo).toBe(undefined); |
10 changes: 10 additions & 0 deletions
10
...el-plugin-proposal-class-static-block/test/fixtures/integration-loose/.new-target/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Base { | ||
constructor() { | ||
this.Foo = class { | ||
static { | ||
this.foo = new.target; | ||
} | ||
} | ||
} | ||
} | ||
expect((new Base).Foo.foo).toBe(undefined); |
10 changes: 10 additions & 0 deletions
10
...l-plugin-proposal-class-static-block/test/fixtures/integration-loose/.new-target/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Base { | ||
constructor() { | ||
this.Foo = class { | ||
static { | ||
this.foo = new.target; | ||
} | ||
} | ||
} | ||
} | ||
expect((new Base).Foo.foo).toBe(undefined); |
2 changes: 1 addition & 1 deletion
2
...-plugin-proposal-class-static-block/test/fixtures/integration-loose/class-binding/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
class Foo { | ||
static bar = 42; | ||
static { | ||
this.foo = Foo.bar; | ||
} | ||
static bar = 42; | ||
} | ||
expect(Foo.foo).toBe(42); |
2 changes: 1 addition & 1 deletion
2
...plugin-proposal-class-static-block/test/fixtures/integration-loose/class-binding/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
class Foo { | ||
static bar = 42; | ||
static { | ||
this.foo = Foo.bar; | ||
} | ||
static bar = 42; | ||
} | ||
expect(Foo.foo).toBe(42); |
2 changes: 1 addition & 1 deletion
2
...gin-proposal-class-static-block/test/fixtures/integration-loose/class-declaration/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
class Foo { | ||
static bar = 42; | ||
static { | ||
this.foo = this.bar; | ||
} | ||
static bar = 42; | ||
} | ||
expect(Foo.foo).toBe(42); |
2 changes: 1 addition & 1 deletion
2
...in-proposal-class-static-block/test/fixtures/integration-loose/class-declaration/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
class Foo { | ||
static bar = 42; | ||
static { | ||
this.foo = this.bar; | ||
} | ||
static bar = 42; | ||
} | ||
expect(Foo.foo).toBe(42); |
10 changes: 8 additions & 2 deletions
10
...l-class-static-block/test/fixtures/integration-loose/multiple-static-initializers/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,14 @@ | ||
class Foo { | ||
static #bar = 21; | ||
static { | ||
this.foo = this.#bar + this.qux; | ||
this.foo = this.#bar; | ||
this.qux1 = this.qux; | ||
} | ||
static qux = 21; | ||
static { | ||
this.qux2 = this.qux; | ||
} | ||
} | ||
expect(Foo.foo).toBe(42); | ||
expect(Foo.foo).toBe(21); | ||
expect(Foo.qux1).toBe(undefined); | ||
expect(Foo.qux2).toBe(21); |
11 changes: 11 additions & 0 deletions
11
...-class-static-block/test/fixtures/integration-loose/multiple-static-initializers/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Foo { | ||
static #bar = 21; | ||
static { | ||
this.foo = this.#bar; | ||
this.qux1 = this.qux; | ||
} | ||
static qux = 21; | ||
static { | ||
this.qux2 = this.qux; | ||
} | ||
} |
26 changes: 26 additions & 0 deletions
26
...class-static-block/test/fixtures/integration-loose/multiple-static-initializers/output.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
var _bar = babelHelpers.classPrivateFieldLooseKey("bar"); | ||
|
||
var _ = babelHelpers.classPrivateFieldLooseKey("_"); | ||
|
||
var _2 = babelHelpers.classPrivateFieldLooseKey("_2"); | ||
|
||
class Foo {} | ||
|
||
Object.defineProperty(Foo, _bar, { | ||
writable: true, | ||
value: 21 | ||
}); | ||
Object.defineProperty(Foo, _, { | ||
writable: true, | ||
value: (() => { | ||
Foo.foo = babelHelpers.classPrivateFieldLooseBase(Foo, _bar)[_bar]; | ||
Foo.qux1 = Foo.qux; | ||
})() | ||
}); | ||
Foo.qux = 21; | ||
Object.defineProperty(Foo, _2, { | ||
writable: true, | ||
value: (() => { | ||
Foo.qux2 = Foo.qux; | ||
})() | ||
}); |
10 changes: 10 additions & 0 deletions
10
...es/babel-plugin-proposal-class-static-block/test/fixtures/integration/.new-target/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class Base { | ||
constructor() { | ||
this.Foo = class { | ||
static { | ||
this.foo = new.target; | ||
} | ||
} | ||
} | ||
} | ||
expect((new Base).Foo.foo).toBe(undefined); |
11 changes: 11 additions & 0 deletions
11
...s/babel-plugin-proposal-class-static-block/test/fixtures/integration/.new-target/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class Base { | ||
constructor() { | ||
this.Foo = class { | ||
static { | ||
// fixme: new.target should be undefined after transformed | ||
this.foo = new.target; | ||
} | ||
} | ||
} | ||
} | ||
expect((new Base).Foo.foo).toBe(undefined); |
2 changes: 1 addition & 1 deletion
2
.../babel-plugin-proposal-class-static-block/test/fixtures/integration/class-binding/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
class Foo { | ||
static bar = 42; | ||
static { | ||
this.foo = Foo.bar; | ||
} | ||
static bar = 42; | ||
} | ||
expect(Foo.foo).toBe(42); |
2 changes: 1 addition & 1 deletion
2
...babel-plugin-proposal-class-static-block/test/fixtures/integration/class-binding/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
class Foo { | ||
static bar = 42; | ||
static { | ||
this.foo = Foo.bar; | ||
} | ||
static bar = 42; | ||
} | ||
expect(Foo.foo).toBe(42); |
2 changes: 1 addition & 1 deletion
2
...el-plugin-proposal-class-static-block/test/fixtures/integration/class-declaration/exec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
class Foo { | ||
static bar = 42; | ||
static { | ||
this.foo = this.bar; | ||
} | ||
static bar = 42; | ||
} | ||
expect(Foo.foo).toBe(42); |
Oops, something went wrong.