-
-
Notifications
You must be signed in to change notification settings - Fork 5.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't leak modifications to the global object
- Loading branch information
1 parent
3a7f89f
commit 139e2a1
Showing
1 changed file
with
20 additions
and
11 deletions.
There are no files selected for viewing
31 changes: 20 additions & 11 deletions
31
packages/babel-plugin-transform-classes/test/fixtures/regression/8499/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,17 +1,26 @@ | ||
// Pretend that `Reflect.construct` isn't supported. | ||
this.Reflect = undefined; | ||
const oldReflect = this.Reflect; | ||
const oldHTMLElement = this.HTMLElement; | ||
|
||
this.HTMLElement = function() { | ||
// Here, `this.HTMLElement` is this function, not the original HTMLElement | ||
// constructor. `this.constructor` should be this function too, but isn't. | ||
constructor = this.constructor; | ||
}; | ||
try { | ||
// Pretend that `Reflect.construct` isn't supported. | ||
this.Reflect = undefined; | ||
|
||
var constructor; | ||
this.HTMLElement = function() { | ||
// Here, `this.HTMLElement` is this function, not the original HTMLElement | ||
// constructor. `this.constructor` should be this function too, but isn't. | ||
constructor = this.constructor; | ||
}; | ||
|
||
class CustomElement extends HTMLElement {}; | ||
new CustomElement(); | ||
var constructor; | ||
|
||
expect(constructor).toBe(CustomElement); | ||
class CustomElement extends HTMLElement {}; | ||
new CustomElement(); | ||
|
||
expect(constructor).toBe(CustomElement); | ||
} finally { | ||
// Restore original env | ||
this.Reflect = oldReflect; | ||
this.HTMLElement = oldHTMLElement; | ||
} | ||
|
||
|