Skip to content

Commit

Permalink
Bug: Polyfill is always enabled.
Browse files Browse the repository at this point in the history
  • Loading branch information
garry-kueez committed Jan 26, 2020
1 parent 0d33ba8 commit ea915d1
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion dist/symbol-es6.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/symbol-es6.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "symbol-es6",
"version": "0.1.2",
"version": "0.1.3",
"description": "ES6 Symbol polyfill in pure ES5",
"main": "symbol-es6.js",
"scripts": {
Expand Down
16 changes: 15 additions & 1 deletion symbol-es6.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@

var ES6 = typeof global.ES6 === "object" ? global.ES6 : (global.ES6 = {});

var isTestMode = global.symbolES6TestingMode || false;

var isArray = Array.isArray;

var objectToString = Object.prototype.toString;
Expand Down Expand Up @@ -73,7 +75,19 @@
};

var isES6Running = function() {
return false; /* Now 'false' for testing purpose */
if (isTestMode)
return false;

var isSymbolSupported = false;
if (typeof Symbol === "function") {
try {
Symbol();
isSymbolSupported = true;
} catch (ignore) {}
} else {
isSymbolSupported = false;
}
return isSymbolSupported; /* Now 'false' for testing purpose */
};

var isObject = function (value) {
Expand Down
1 change: 1 addition & 0 deletions test/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
<head>
<meta charset="UTF-8">
<title>Title</title>
<script>window.symbolES6TestingMode = true;</script>
<script src="../symbol-es6.js"></script>
</head>
<body>
Expand Down
2 changes: 1 addition & 1 deletion test/test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
"use strict";

global.symbolES6TestingMode = true
var ES6 = require("../symbol-es6");

console.log(Symbol("bar") === Symbol("bar")); //false
Expand Down

0 comments on commit ea915d1

Please sign in to comment.