-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/es2015): Fix injection location of
this
for getter/setter pr…
…operties (#8993) **Related issue:** - Closes #8992 --------- Co-authored-by: magic-akari <akari.ccino@gmail.com>
- Loading branch information
1 parent
4e1adfc
commit 09121a6
Showing
6 changed files
with
104 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"jsc": { | ||
"parser": { | ||
"syntax": "ecmascript", | ||
"jsx": false | ||
}, | ||
"target": "es5", | ||
"loose": false, | ||
"minify": { | ||
"compress": false, | ||
"mangle": false | ||
} | ||
}, | ||
"module": { | ||
"type": "es6" | ||
}, | ||
"minify": false, | ||
"isModule": false | ||
} |
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 @@ | ||
const myObj = { | ||
get foo() { | ||
return () => this; | ||
}, | ||
}; | ||
|
||
const fn = myObj.foo; | ||
|
||
// should be true | ||
console.log(fn() === myObj); |
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,13 @@ | ||
const o1 = { | ||
x: "a", | ||
foo() { | ||
const o2 = { | ||
get [(() => this.x)()]() { | ||
return 1; | ||
}, | ||
}; | ||
console.log(o2.a === 1); | ||
}, | ||
}; | ||
|
||
o1.foo(); |
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 @@ | ||
var myObj = { | ||
get foo () { | ||
var _this = this; | ||
return function() { | ||
return _this; | ||
}; | ||
} | ||
}; | ||
var fn = myObj.foo; | ||
console.log(fn() === myObj); |
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,19 @@ | ||
var _define_enumerable_properties = require("@swc/helpers/_/_define_enumerable_properties"); | ||
var o1 = { | ||
x: "a", | ||
foo: function foo() { | ||
var _this = this; | ||
var _obj, _mutatorMap = {}; | ||
var o2 = (_obj = {}, _mutatorMap[function() { | ||
return _this.x; | ||
}()] = _mutatorMap[function() { | ||
return _this.x; | ||
}()] || {}, _mutatorMap[function() { | ||
return _this.x; | ||
}()].get = function() { | ||
return 1; | ||
}, _define_enumerable_properties._(_obj, _mutatorMap), _obj); | ||
console.log(o2.a === 1); | ||
} | ||
}; | ||
o1.foo(); |
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