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
40f9ab9c
Commit
40f9ab9c
authored
Oct 16, 2012
by
jaubourg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
better, more maintainable version of the prefilters execution and transport selection
parent
7d2e99fb
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
35 deletions
+20
-35
ajax.js
src/ajax.js
+20
-35
No files found.
src/ajax.js
View file @
40f9ab9c
...
@@ -88,43 +88,28 @@ function addToPrefiltersOrTransports( structure ) {
...
@@ -88,43 +88,28 @@ function addToPrefiltersOrTransports( structure ) {
}
}
// Base inspection function for prefilters and transports
// Base inspection function for prefilters and transports
function
inspectPrefiltersOrTransports
(
structure
,
options
,
originalOptions
,
jqXHR
,
function
inspectPrefiltersOrTransports
(
structure
,
options
,
originalOptions
,
jqXHR
)
{
dataType
/* internal */
,
inspected
/* internal */
)
{
dataType
=
dataType
||
options
.
dataTypes
[
0
];
var
inspected
=
{},
inspected
=
inspected
||
{}
;
seekingTransport
=
(
structure
===
transports
)
;
function
inspect
(
dataType
)
{
var
selected
;
inspected
[
dataType
]
=
true
;
inspected
[
dataType
]
=
true
;
jQuery
.
each
(
structure
[
dataType
]
||
[],
function
(
_
,
prefilterOrFactory
)
{
var
selection
,
var
dataTypeOrTransport
=
prefilterOrFactory
(
options
,
originalOptions
,
jqXHR
);
list
=
structure
[
dataType
],
if
(
typeof
dataTypeOrTransport
===
"string"
&&
!
seekingTransport
&&
!
inspected
[
dataTypeOrTransport
]
)
{
i
=
0
,
options
.
dataTypes
.
unshift
(
dataTypeOrTransport
);
length
=
list
?
list
.
length
:
0
,
inspect
(
dataTypeOrTransport
);
executeOnly
=
(
structure
===
prefilters
);
return
false
;
}
else
if
(
seekingTransport
)
{
for
(
;
i
<
length
&&
(
executeOnly
||
!
selection
);
i
++
)
{
return
!
(
selected
=
dataTypeOrTransport
);
selection
=
list
[
i
](
options
,
originalOptions
,
jqXHR
);
// If we got redirected to another dataType
// we try there if executing only and not done already
if
(
typeof
selection
===
"string"
)
{
if
(
!
executeOnly
||
inspected
[
selection
]
)
{
selection
=
undefined
;
}
else
{
options
.
dataTypes
.
unshift
(
selection
);
selection
=
inspectPrefiltersOrTransports
(
structure
,
options
,
originalOptions
,
jqXHR
,
selection
,
inspected
);
}
}
}
});
return
selected
;
}
}
// If we're only executing or nothing was selected
// we try the catchall dataType if not done already
return
inspect
(
options
.
dataTypes
[
0
]
)
||
!
inspected
[
"*"
]
&&
inspect
(
"*"
);
if
(
(
executeOnly
||
!
selection
)
&&
!
inspected
[
"*"
]
)
{
selection
=
inspectPrefiltersOrTransports
(
structure
,
options
,
originalOptions
,
jqXHR
,
"*"
,
inspected
);
}
// unnecessary when only executing (prefilters)
// but it'll be ignored by the caller in that case
return
selection
;
}
}
// A special extend for ajax options
// A special extend for ajax options
...
...
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