Skip to content

Commit

Permalink
One more fallback for Qt Script bug, #173
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Mar 8, 2016
1 parent 52b288c commit 2d9cead
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions library/modules/es6.date.to-json.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
'use strict';
var $export = require('./_export')
, toObject = require('./_to-object')
, toPrimitive = require('./_to-primitive');
, toPrimitive = require('./_to-primitive')
, getTime = Date.prototype.getTime;

$export($export.P + $export.F * require('./_fails')(function(){
return new Date(NaN).toJSON() !== null || Date.prototype.toJSON.call({toISOString: function(){ return 1; }}) !== 1;
}), 'Date', {
toJSON: function toJSON(key){
var O = toObject(this)
, pv = toPrimitive(O);
// fallback for old WebKit
, pv = O instanceof Date ? getTime.call(this) : toPrimitive(O);
return typeof pv == 'number' && !isFinite(pv) ? null : O.toISOString();
}
});
6 changes: 4 additions & 2 deletions modules/es6.date.to-json.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,16 @@
'use strict';
var $export = require('./_export')
, toObject = require('./_to-object')
, toPrimitive = require('./_to-primitive');
, toPrimitive = require('./_to-primitive')
, getTime = Date.prototype.getTime;

$export($export.P + $export.F * require('./_fails')(function(){
return new Date(NaN).toJSON() !== null || Date.prototype.toJSON.call({toISOString: function(){ return 1; }}) !== 1;
}), 'Date', {
toJSON: function toJSON(key){
var O = toObject(this)
, pv = toPrimitive(O);
// fallback for old WebKit
, pv = O instanceof Date ? getTime.call(this) : toPrimitive(O);
return typeof pv == 'number' && !isFinite(pv) ? null : O.toISOString();
}
});

0 comments on commit 2d9cead

Please sign in to comment.