Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
J
jquery
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
夏彬
jquery
Commits
b6e99eb4
Commit
b6e99eb4
authored
Jun 07, 2014
by
Richard Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Core: Work around loss of precision from parseFloat
Fixes #15100
parent
6cb17c8e
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
2 deletions
+4
-2
core.js
src/core.js
+2
-1
core.js
test/unit/core.js
+2
-1
No files found.
src/core.js
View file @
b6e99eb4
...
@@ -216,7 +216,8 @@ jQuery.extend({
...
@@ -216,7 +216,8 @@ jQuery.extend({
// parseFloat NaNs numeric-cast false positives (null|true|false|"")
// parseFloat NaNs numeric-cast false positives (null|true|false|"")
// ...but misinterprets leading-number strings, particularly hex literals ("0x...")
// ...but misinterprets leading-number strings, particularly hex literals ("0x...")
// subtraction forces infinities to NaN
// subtraction forces infinities to NaN
return
!
jQuery
.
isArray
(
obj
)
&&
obj
-
parseFloat
(
obj
)
>=
0
;
// adding 1 corrects loss of precision from parseFloat (#15100)
return
!
jQuery
.
isArray
(
obj
)
&&
(
obj
-
parseFloat
(
obj
)
+
1
)
>=
0
;
},
},
isEmptyObject
:
function
(
obj
)
{
isEmptyObject
:
function
(
obj
)
{
...
...
test/unit/core.js
View file @
b6e99eb4
...
@@ -462,7 +462,7 @@ test("isFunction", function() {
...
@@ -462,7 +462,7 @@ test("isFunction", function() {
});
});
test
(
"isNumeric"
,
function
()
{
test
(
"isNumeric"
,
function
()
{
expect
(
3
7
);
expect
(
3
8
);
var
t
=
jQuery
.
isNumeric
,
var
t
=
jQuery
.
isNumeric
,
Traditionalists
=
/** @constructor */
function
(
n
)
{
Traditionalists
=
/** @constructor */
function
(
n
)
{
...
@@ -490,6 +490,7 @@ test( "isNumeric", function() {
...
@@ -490,6 +490,7 @@ test( "isNumeric", function() {
ok
(
t
(
"4.536"
),
"Positive floating point string"
);
ok
(
t
(
"4.536"
),
"Positive floating point string"
);
ok
(
t
(
-
2.6
),
"Negative floating point number"
);
ok
(
t
(
-
2.6
),
"Negative floating point number"
);
ok
(
t
(
3.1415
),
"Positive floating point number"
);
ok
(
t
(
3.1415
),
"Positive floating point number"
);
ok
(
t
(
1.5999999999999999
),
"Very precise floating point number"
);
ok
(
t
(
8
e5
),
"Exponential notation"
);
ok
(
t
(
8
e5
),
"Exponential notation"
);
ok
(
t
(
"123e-2"
),
"Exponential notation string"
);
ok
(
t
(
"123e-2"
),
"Exponential notation string"
);
ok
(
t
(
answer
),
"Custom .toString returning number"
);
ok
(
t
(
answer
),
"Custom .toString returning number"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment