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
2c1d2b1a
Commit
2c1d2b1a
authored
Dec 06, 2011
by
Mike Sherov
Committed by
Dave Methvin
Dec 06, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #10754. Have jQuery.swap() return the value of its callback.
parent
0fcfac75
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
11 additions
and
14 deletions
+11
-14
css.js
src/css.js
+11
-14
No files found.
src/css.js
View file @
2c1d2b1a
...
@@ -140,20 +140,23 @@ jQuery.extend({
...
@@ -140,20 +140,23 @@ jQuery.extend({
// A method for quickly swapping in/out CSS properties to get correct calculations
// A method for quickly swapping in/out CSS properties to get correct calculations
swap
:
function
(
elem
,
options
,
callback
)
{
swap
:
function
(
elem
,
options
,
callback
)
{
var
old
=
{};
var
old
=
{},
ret
,
name
;
// Remember the old values, and insert the new ones
// Remember the old values, and insert the new ones
for
(
var
name
in
options
)
{
for
(
name
in
options
)
{
old
[
name
]
=
elem
.
style
[
name
];
old
[
name
]
=
elem
.
style
[
name
];
elem
.
style
[
name
]
=
options
[
name
];
elem
.
style
[
name
]
=
options
[
name
];
}
}
callback
.
call
(
elem
);
ret
=
callback
.
call
(
elem
);
// Revert the old values
// Revert the old values
for
(
name
in
options
)
{
for
(
name
in
options
)
{
elem
.
style
[
name
]
=
old
[
name
];
elem
.
style
[
name
]
=
old
[
name
];
}
}
return
ret
;
}
}
});
});
...
@@ -163,18 +166,14 @@ jQuery.curCSS = jQuery.css;
...
@@ -163,18 +166,14 @@ jQuery.curCSS = jQuery.css;
jQuery
.
each
([
"height"
,
"width"
],
function
(
i
,
name
)
{
jQuery
.
each
([
"height"
,
"width"
],
function
(
i
,
name
)
{
jQuery
.
cssHooks
[
name
]
=
{
jQuery
.
cssHooks
[
name
]
=
{
get
:
function
(
elem
,
computed
,
extra
)
{
get
:
function
(
elem
,
computed
,
extra
)
{
var
val
;
if
(
computed
)
{
if
(
computed
)
{
if
(
elem
.
offsetWidth
!==
0
)
{
if
(
elem
.
offsetWidth
!==
0
)
{
return
getWH
(
elem
,
name
,
extra
);
return
getWH
(
elem
,
name
,
extra
);
}
else
{
}
else
{
jQuery
.
swap
(
elem
,
cssShow
,
function
()
{
return
jQuery
.
swap
(
elem
,
cssShow
,
function
()
{
val
=
getWH
(
elem
,
name
,
extra
);
return
getWH
(
elem
,
name
,
extra
);
});
});
}
}
return
val
;
}
}
},
},
...
@@ -243,15 +242,13 @@ jQuery(function() {
...
@@ -243,15 +242,13 @@ jQuery(function() {
get
:
function
(
elem
,
computed
)
{
get
:
function
(
elem
,
computed
)
{
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
// Work around by temporarily setting element display to inline-block
// Work around by temporarily setting element display to inline-block
var
ret
;
return
jQuery
.
swap
(
elem
,
{
"display"
:
"inline-block"
},
function
()
{
jQuery
.
swap
(
elem
,
{
"display"
:
"inline-block"
},
function
()
{
if
(
computed
)
{
if
(
computed
)
{
ret
=
curCSS
(
elem
,
"margin-right"
,
"marginRight"
);
ret
urn
curCSS
(
elem
,
"margin-right"
,
"marginRight"
);
}
else
{
}
else
{
ret
=
elem
.
style
.
marginRight
;
ret
urn
elem
.
style
.
marginRight
;
}
}
});
});
return
ret
;
}
}
};
};
}
}
...
...
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