Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9f2cbc4
commit 3956c75
Showing
4 changed files
with
76 additions
and
6 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
18 changes: 18 additions & 0 deletions
18
...ages/babel-plugin-transform-block-scoping/test/fixtures/general/for-without-block/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,18 @@ | ||
function proxyObserver(properties) { | ||
for (let key in properties) | ||
if (properties[key].observer) { | ||
let base = properties[key].observer; | ||
properties[key].observer = () => { | ||
return base.apply(this); | ||
}; | ||
} | ||
|
||
return properties; | ||
} | ||
|
||
const results = proxyObserver([ | ||
{ observer: () => 1 }, | ||
{ observer: () => 2 }, | ||
]) | ||
expect(results[0].observer()).toBe(1) | ||
expect(results[1].observer()).toBe(2) |
23 changes: 23 additions & 0 deletions
23
...ges/babel-plugin-transform-block-scoping/test/fixtures/general/for-without-block/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,23 @@ | ||
function proxyObserver(component) { | ||
for (let key in component.properties) | ||
if (component.properties[key].observer) { | ||
let base = component.properties[key].observer; | ||
component.properties[key].observer = () => { | ||
base.apply(this); | ||
}; | ||
} | ||
|
||
return component; | ||
} | ||
|
||
function proxyObserver2(component) { | ||
for (let key of component.properties) | ||
while (1) { | ||
let base = component.properties[key].observer; | ||
component.properties[key].observer = () => { | ||
base.apply(this); | ||
}; | ||
} | ||
|
||
return component; | ||
} |
30 changes: 30 additions & 0 deletions
30
...es/babel-plugin-transform-block-scoping/test/fixtures/general/for-without-block/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,30 @@ | ||
function proxyObserver(component) { | ||
var _this = this; | ||
var _loop = function () { | ||
if (component.properties[key].observer) { | ||
var base = component.properties[key].observer; | ||
component.properties[key].observer = function () { | ||
base.apply(_this); | ||
}; | ||
} | ||
}; | ||
for (var key in component.properties) { | ||
_loop(); | ||
} | ||
return component; | ||
} | ||
function proxyObserver2(component) { | ||
var _this2 = this; | ||
for (var key of component.properties) { | ||
var _loop2 = function () { | ||
var base = component.properties[key].observer; | ||
component.properties[key].observer = function () { | ||
base.apply(_this2); | ||
}; | ||
}; | ||
while (1) { | ||
_loop2(); | ||
} | ||
} | ||
return component; | ||
} |