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
166b9d25
Commit
166b9d25
authored
Dec 06, 2011
by
Rick Waldron
Committed by
Dave Methvin
Dec 06, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #10466. jQuery.param() should treat object-wrapped primitives as primitives.
parent
6c2a501d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
1 deletion
+14
-1
ajax.js
src/ajax.js
+1
-1
ajax.js
test/unit/ajax.js
+13
-0
No files found.
src/ajax.js
View file @
166b9d25
...
@@ -818,7 +818,7 @@ function buildParams( prefix, obj, traditional, add ) {
...
@@ -818,7 +818,7 @@ function buildParams( prefix, obj, traditional, add ) {
}
}
});
});
}
else
if
(
!
traditional
&&
obj
!=
null
&&
typeof
obj
===
"object"
)
{
}
else
if
(
!
traditional
&&
jQuery
.
isPlainObject
(
obj
)
)
{
// Serialize object item.
// Serialize object item.
for
(
var
name
in
obj
)
{
for
(
var
name
in
obj
)
{
buildParams
(
prefix
+
"["
+
name
+
"]"
,
obj
[
name
],
traditional
,
add
);
buildParams
(
prefix
+
"["
+
name
+
"]"
,
obj
[
name
],
traditional
,
add
);
...
...
test/unit/ajax.js
View file @
166b9d25
...
@@ -1031,6 +1031,19 @@ test("jQuery.param()", function() {
...
@@ -1031,6 +1031,19 @@ test("jQuery.param()", function() {
equal
(
jQuery
.
param
(
params
,
false
),
"test%5Blength%5D=3&test%5Bfoo%5D=bar"
,
"Sub-object with a length property"
);
equal
(
jQuery
.
param
(
params
,
false
),
"test%5Blength%5D=3&test%5Bfoo%5D=bar"
,
"Sub-object with a length property"
);
});
});
test
(
"jQuery.param() Constructed prop values"
,
function
()
{
expect
(
3
);
var
params
=
{
"test"
:
new
String
(
"foo"
)
};
equal
(
jQuery
.
param
(
params
,
false
),
"test=foo"
,
"Do not mistake new String() for a plain object"
);
params
=
{
"test"
:
new
Number
(
5
)
};
equal
(
jQuery
.
param
(
params
,
false
),
"test=5"
,
"Do not mistake new Number() for a plain object"
);
params
=
{
"test"
:
new
Date
()
};
ok
(
jQuery
.
param
(
params
,
false
),
"(Non empty string returned) Do not mistake new Date() for a plain object"
);
});
test
(
"synchronous request"
,
function
()
{
test
(
"synchronous request"
,
function
()
{
expect
(
1
);
expect
(
1
);
ok
(
/^{ "data"/
.
test
(
jQuery
.
ajax
({
url
:
url
(
"data/json_obj.js"
),
dataType
:
"text"
,
async
:
false
}).
responseText
),
"check returned text"
);
ok
(
/^{ "data"/
.
test
(
jQuery
.
ajax
({
url
:
url
(
"data/json_obj.js"
),
dataType
:
"text"
,
async
:
false
}).
responseText
),
"check returned text"
);
...
...
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