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
574ae3b1
Commit
574ae3b1
authored
Jan 21, 2011
by
Gianni Chiappetta
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added: Backcompatibility with old proxy syntax.
parent
a03f040d
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
1 deletion
+11
-1
core.js
src/core.js
+6
-0
core.js
test/unit/core.js
+5
-1
No files found.
src/core.js
View file @
574ae3b1
...
@@ -739,6 +739,12 @@ jQuery.extend({
...
@@ -739,6 +739,12 @@ jQuery.extend({
proxy
:
function
(
fn
,
context
)
{
proxy
:
function
(
fn
,
context
)
{
var
args
,
proxy
;
var
args
,
proxy
;
// XXX BACKCOMPAT: Support old string method.
if
(
typeof
context
===
"string"
)
{
fn
=
fn
[
context
];
context
=
arguments
[
0
];
}
// Quick check to determine if target is callable, in the spec
// Quick check to determine if target is callable, in the spec
// this throws a TypeError, but we will just return undefined.
// this throws a TypeError, but we will just return undefined.
if
(
!
jQuery
.
isFunction
(
fn
)
)
{
if
(
!
jQuery
.
isFunction
(
fn
)
)
{
...
...
test/unit/core.js
View file @
574ae3b1
...
@@ -869,7 +869,7 @@ test("jQuery.isEmptyObject", function(){
...
@@ -869,7 +869,7 @@ test("jQuery.isEmptyObject", function(){
});
});
test
(
"jQuery.proxy"
,
function
(){
test
(
"jQuery.proxy"
,
function
(){
expect
(
5
);
expect
(
6
);
var
test
=
function
(){
equals
(
this
,
thisObject
,
"Make sure that scope is set properly."
);
};
var
test
=
function
(){
equals
(
this
,
thisObject
,
"Make sure that scope is set properly."
);
};
var
thisObject
=
{
foo
:
"bar"
,
method
:
test
};
var
thisObject
=
{
foo
:
"bar"
,
method
:
test
};
...
@@ -890,6 +890,10 @@ test("jQuery.proxy", function(){
...
@@ -890,6 +890,10 @@ test("jQuery.proxy", function(){
// Partial application w/ normal arguments
// Partial application w/ normal arguments
var
test3
=
function
(
a
,
b
){
equals
(
b
,
"normal"
,
"Ensure arguments can be pre-applied and passed as usual."
);
};
var
test3
=
function
(
a
,
b
){
equals
(
b
,
"normal"
,
"Ensure arguments can be pre-applied and passed as usual."
);
};
jQuery
.
proxy
(
test3
,
null
,
"pre-applied"
)(
"normal"
);
jQuery
.
proxy
(
test3
,
null
,
"pre-applied"
)(
"normal"
);
// Test old syntax
var
test4
=
{
meth
:
function
(
a
){
equals
(
a
,
"boom"
,
"Ensure old syntax works."
);
}
};
jQuery
.
proxy
(
test4
,
"meth"
)(
"boom"
);
});
});
test
(
"jQuery.parseJSON"
,
function
(){
test
(
"jQuery.parseJSON"
,
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