Comments (7)
json2.js Date.prototoype.toJSON is also not generic. If json2.js is updated to handle extended dates correctly but not to be generic then the following check would fix things.
if (!Date.prototype.toJSON ||
// does Date.prototype.toJSON not do extended years properly?
((new Date(-62198755200000)).toJSON().indexOf('-000001') === -1) ||
// is Date.prototype.toJSON non-generic?
(function() {
var str = 'abc';
try {
return Date.prototype.toJSON.call({toISOString:function(){return str;}}) !== str;
}
catch (err) {
return true;
}
}())) {
from es5-shim.
Thanks, @petermichaux. Good to cross paths again!
from es5-shim.
I admit the above feature test is ugly.
A workaround that could be documented in the README?...
<script src="json2.js" type="text/javascript"></script>
<script type="text/javascript">
delete Date.prototype.toJSON
</script>
<script src="es5-shim.js" type="text/javascript"></script>
from es5-shim.
By the way, Crockford closed my tickets about improving the Date.prototype.toJSON in his json2.js.
from es5-shim.
What about something like this?
if (!Date.prototype.toJSON ||
// does Date.prototype.toJSON not do extended years properly?
!~((new Date(-62198755200000)).toJSON().indexOf('-000001')) ||
// is Date.prototype.toJSON non-generic?
~(function() {
try {
return Date.prototype.toJSON.call({toISOString:function(){return -1;}});
} catch (err) {
return true;
}
}())) {
from es5-shim.
Relevant:
douglascrockford/JSON-js#27
douglascrockford/JSON-js#25
from es5-shim.
Additional json2.js
issues:
douglascrockford/JSON-js#28
from es5-shim.
Related Issues (20)
- All V8 versions have the Date shim loaded. HOT 1
- Rounding errors with toExponential in Edge 15/16 HOT 4
- IE9 error: Redeclaration of const property HOT 5
- Something in the shim causes Chrome to throw a warning HOT 3
- 4.5.11 got a tag, but not a full release HOT 2
- `hasAutomationEqualityBug` triggers deprecation warnings in Firefox
- Cannot convert undefined or null to object PropTypes.shape() HOT 9
- Question: Why concatenate Symbols with a string without assigning it to a variable? HOT 6
- Why not set bound.prototype = target.prototype directly? HOT 3
- in ie8 Object.keys failed this conversion HOT 3
- Action required: Greenkeeper could not be activated 🚨
- String#lastIndexOf has a shallow-wrapper shim that does nothing and always gets applied HOT 1
- Dependency Dashboard
- Conflict ES5-shim(sham) 4.5.15 and ES6-shim(sham) 0.35.x HOT 19
- Please change the name of the default branch HOT 1
- External URL linking to spam websites HOT 2
- errors with Object.defineProperty under ie8 since 4.6.3 HOT 6
- Incompatibility with awilix HOT 17
- Invalid Date on Safari HOT 2
- ⚠️ `webkitStorageInfo` is going away HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from es5-shim.