Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[static private] Unify loose handling of static and instance props (#…
- Loading branch information
1 parent
262787b
commit d4e23b5
Showing
11 changed files
with
102 additions
and
144 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
10 changes: 4 additions & 6 deletions
10
...gin-proposal-class-properties/test/fixtures/private-loose/non-block-arrow-func/output.mjs
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,18 +1,16 @@ | ||
export default (param => { | ||
var _class, _temp; | ||
var _class, _temp, _props; | ||
|
||
return _temp = _class = class App { | ||
getParam() { | ||
return param; | ||
} | ||
|
||
}, Object.defineProperty(_class, "_props", { | ||
}, _props = babelHelpers.classPrivateFieldLooseKey("props"), Object.defineProperty(_class, _props, { | ||
writable: true, | ||
value: { | ||
prop1: 'prop1', | ||
prop2: 'prop2' | ||
}, | ||
enumerable: false, | ||
configurable: false, | ||
writable: true | ||
} | ||
}), _temp; | ||
}); |
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
22 changes: 12 additions & 10 deletions
22
...bel-plugin-proposal-class-properties/test/fixtures/private-loose/static-export/output.mjs
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,14 +1,16 @@ | ||
export class MyClass {} | ||
Object.defineProperty(MyClass, "_property", { | ||
value: value, | ||
enumerable: false, | ||
configurable: false, | ||
writable: true | ||
|
||
var _property = babelHelpers.classPrivateFieldLooseKey("property"); | ||
|
||
Object.defineProperty(MyClass, _property, { | ||
writable: true, | ||
value: value | ||
}); | ||
export default class MyClass2 {} | ||
Object.defineProperty(MyClass2, "_property2", { | ||
value: value, | ||
enumerable: false, | ||
configurable: false, | ||
writable: true | ||
|
||
var _property2 = babelHelpers.classPrivateFieldLooseKey("property"); | ||
|
||
Object.defineProperty(MyClass2, _property2, { | ||
writable: true, | ||
value: value | ||
}); |
10 changes: 4 additions & 6 deletions
10
...-plugin-proposal-class-properties/test/fixtures/private-loose/static-infer-name/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 |
---|---|---|
@@ -1,8 +1,6 @@ | ||
var _class, _temp; | ||
var _class, _temp, _num; | ||
|
||
var Foo = (_temp = _class = class Foo {}, Object.defineProperty(_class, "_num", { | ||
value: 0, | ||
enumerable: false, | ||
configurable: false, | ||
writable: true | ||
var Foo = (_temp = _class = class Foo {}, _num = babelHelpers.classPrivateFieldLooseKey("num"), Object.defineProperty(_class, _num, { | ||
writable: true, | ||
value: 0 | ||
}), _temp); |
30 changes: 15 additions & 15 deletions
30
...l-plugin-proposal-class-properties/test/fixtures/private-loose/static-inherited/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 |
---|---|---|
@@ -1,41 +1,41 @@ | ||
class Base { | ||
static getThis() { | ||
return babelHelpers.classStaticPrivateFieldLooseBase(this, Base)._foo; | ||
return babelHelpers.classPrivateFieldLooseBase(this, _foo)[_foo]; | ||
} | ||
|
||
static updateThis(val) { | ||
return babelHelpers.classStaticPrivateFieldLooseBase(this, Base)._foo = val; | ||
return babelHelpers.classPrivateFieldLooseBase(this, _foo)[_foo] = val; | ||
} | ||
|
||
static getClass() { | ||
return babelHelpers.classStaticPrivateFieldLooseBase(Base, Base)._foo; | ||
return babelHelpers.classPrivateFieldLooseBase(Base, _foo)[_foo]; | ||
} | ||
|
||
static updateClass(val) { | ||
return babelHelpers.classStaticPrivateFieldLooseBase(Base, Base)._foo = val; | ||
return babelHelpers.classPrivateFieldLooseBase(Base, _foo)[_foo] = val; | ||
} | ||
|
||
} | ||
|
||
Object.defineProperty(Base, "_foo", { | ||
value: 1, | ||
enumerable: false, | ||
configurable: false, | ||
writable: true | ||
var _foo = babelHelpers.classPrivateFieldLooseKey("foo"); | ||
|
||
Object.defineProperty(Base, _foo, { | ||
writable: true, | ||
value: 1 | ||
}); | ||
|
||
class Sub1 extends Base { | ||
static update(val) { | ||
return babelHelpers.classStaticPrivateFieldLooseBase(this, Sub1)._foo2 = val; | ||
return babelHelpers.classPrivateFieldLooseBase(this, _foo2)[_foo2] = val; | ||
} | ||
|
||
} | ||
|
||
Object.defineProperty(Sub1, "_foo2", { | ||
value: 2, | ||
enumerable: false, | ||
configurable: false, | ||
writable: true | ||
var _foo2 = babelHelpers.classPrivateFieldLooseKey("foo"); | ||
|
||
Object.defineProperty(Sub1, _foo2, { | ||
writable: true, | ||
value: 2 | ||
}); | ||
|
||
class Sub2 extends Base {} |
14 changes: 7 additions & 7 deletions
14
...l-plugin-proposal-class-properties/test/fixtures/private-loose/static-undefined/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 |
---|---|---|
@@ -1,17 +1,17 @@ | ||
class Foo { | ||
static test() { | ||
return babelHelpers.classStaticPrivateFieldLooseBase(Foo, Foo)._bar; | ||
return babelHelpers.classPrivateFieldLooseBase(Foo, _bar)[_bar]; | ||
} | ||
|
||
test() { | ||
return babelHelpers.classStaticPrivateFieldLooseBase(Foo, Foo)._bar; | ||
return babelHelpers.classPrivateFieldLooseBase(Foo, _bar)[_bar]; | ||
} | ||
|
||
} | ||
|
||
Object.defineProperty(Foo, "_bar", { | ||
value: void 0, | ||
enumerable: false, | ||
configurable: false, | ||
writable: true | ||
var _bar = babelHelpers.classPrivateFieldLooseKey("bar"); | ||
|
||
Object.defineProperty(Foo, _bar, { | ||
writable: true, | ||
value: void 0 | ||
}); |
Oops, something went wrong.