This repository has been archived by the owner on Feb 26, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 407
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: use symbols if possible for private properties on exposed objects
fix #172
- Loading branch information
Showing
6 changed files
with
84 additions
and
40 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/** | ||
* Creates keys for `private` properties on exposed objects to minimize interactions with other codebases. | ||
* The key will be a Symbol if the host supports it; otherwise a prefixed string. | ||
*/ | ||
if (typeof Symbol !== 'undefined') { | ||
function create(name) { | ||
return Symbol(name); | ||
} | ||
} else { | ||
function create(name) { | ||
return '_zone$' + name; | ||
} | ||
} | ||
|
||
var commonKeys = { | ||
addEventListener: create('addEventListener'), | ||
removeEventListener: create('removeEventListener') | ||
}; | ||
|
||
module.exports = { | ||
create: create, | ||
common: commonKeys | ||
}; |
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
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