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
d8289964
Commit
d8289964
authored
Jan 13, 2012
by
Rick Waldron
Committed by
Dave Methvin
Jan 13, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #10978: Let jQuery.param() accept non-native constructed objects.
parent
6c8dd7e7
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
14 additions
and
6 deletions
+14
-6
ajax.js
src/ajax.js
+2
-2
ajax.js
test/unit/ajax.js
+12
-4
No files found.
src/ajax.js
View file @
d8289964
...
@@ -814,11 +814,11 @@ function buildParams( prefix, obj, traditional, add ) {
...
@@ -814,11 +814,11 @@ function buildParams( prefix, obj, traditional, add ) {
// a server error. Possible fixes are to modify rack's
// a server error. Possible fixes are to modify rack's
// deserialization algorithm or to provide an option or flag
// deserialization algorithm or to provide an option or flag
// to force array serialization to be shallow.
// to force array serialization to be shallow.
buildParams
(
prefix
+
"["
+
(
typeof
v
===
"object"
||
jQuery
.
isArray
(
v
)
?
i
:
""
)
+
"]"
,
v
,
traditional
,
add
);
buildParams
(
prefix
+
"["
+
(
typeof
v
===
"object"
?
i
:
""
)
+
"]"
,
v
,
traditional
,
add
);
}
}
});
});
}
else
if
(
!
traditional
&&
jQuery
.
isPlainObject
(
obj
)
)
{
}
else
if
(
!
traditional
&&
jQuery
.
type
(
obj
)
===
"object"
)
{
// 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 @
d8289964
...
@@ -1032,16 +1032,24 @@ test("jQuery.param()", function() {
...
@@ -1032,16 +1032,24 @@ test("jQuery.param()", function() {
});
});
test
(
"jQuery.param() Constructed prop values"
,
function
()
{
test
(
"jQuery.param() Constructed prop values"
,
function
()
{
expect
(
3
);
expect
(
4
);
var
params
=
{
"test"
:
new
String
(
"foo"
)
};
function
Record
()
{
this
.
prop
=
"val"
;
}
var
params
=
{
"test"
:
new
String
(
"foo"
)
};
equal
(
jQuery
.
param
(
params
,
false
),
"test=foo"
,
"Do not mistake new String() for a plain object"
);
equal
(
jQuery
.
param
(
params
,
false
),
"test=foo"
,
"Do not mistake new String() for a plain object"
);
params
=
{
"test"
:
new
Number
(
5
)
};
params
=
{
"test"
:
new
Number
(
5
)
};
equal
(
jQuery
.
param
(
params
,
false
),
"test=5"
,
"Do not mistake new Number() for a plain object"
);
equal
(
jQuery
.
param
(
params
,
false
),
"test=5"
,
"Do not mistake new Number() for a plain object"
);
params
=
{
"test"
:
new
Date
()
};
params
=
{
"test"
:
new
Date
()
};
ok
(
jQuery
.
param
(
params
,
false
),
"(Non empty string returned) Do not mistake new Date() for a plain object"
);
ok
(
jQuery
.
param
(
params
,
false
),
"(Non empty string returned) Do not mistake new Date() for a plain object"
);
// should allow non-native constructed objects
params
=
{
"test"
:
new
Record
()
};
equal
(
jQuery
.
param
(
params
,
false
),
jQuery
.
param
({
"test"
:
{
prop
:
"val"
}
}),
"Allow non-native constructed objects"
);
});
});
test
(
"synchronous request"
,
function
()
{
test
(
"synchronous request"
,
function
()
{
...
...
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