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
df7847bc
Commit
df7847bc
authored
Mar 04, 2013
by
Michał Gołębiowski
Committed by
Dave Methvin
Apr 04, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #13543. offsetWidth is wrong on non-1 zoom. Close gh-1218.
parent
01fcdba2
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
54 additions
and
23 deletions
+54
-23
core.js
src/core.js
+23
-0
css.js
src/css.js
+0
-21
support.js
src/support.js
+7
-2
boxSizing.html
test/data/support/boxSizing.html
+19
-0
support.js
test/unit/support.js
+5
-0
No files found.
src/core.js
View file @
df7847bc
...
...
@@ -865,6 +865,29 @@ jQuery.extend({
now
:
function
()
{
return
(
new
Date
()
).
getTime
();
},
// A method for quickly swapping in/out CSS properties to get correct calculations.
// Note: this method belongs to the css module but it's needed here for the support module.
// If support gets modularized, this method should be moved back to the css module.
swap
:
function
(
elem
,
options
,
callback
,
args
)
{
var
ret
,
name
,
old
=
{};
// Remember the old values, and insert the new ones
for
(
name
in
options
)
{
old
[
name
]
=
elem
.
style
[
name
];
elem
.
style
[
name
]
=
options
[
name
];
}
ret
=
callback
.
apply
(
elem
,
args
||
[]
);
// Revert the old values
for
(
name
in
options
)
{
elem
.
style
[
name
]
=
old
[
name
];
}
return
ret
;
}
});
...
...
src/css.js
View file @
df7847bc
...
...
@@ -279,27 +279,6 @@ jQuery.extend({
return
extra
===
true
||
jQuery
.
isNumeric
(
num
)
?
num
||
0
:
val
;
}
return
val
;
},
// A method for quickly swapping in/out CSS properties to get correct calculations
swap
:
function
(
elem
,
options
,
callback
,
args
)
{
var
ret
,
name
,
old
=
{};
// Remember the old values, and insert the new ones
for
(
name
in
options
)
{
old
[
name
]
=
elem
.
style
[
name
];
elem
.
style
[
name
]
=
options
[
name
];
}
ret
=
callback
.
apply
(
elem
,
args
||
[]
);
// Revert the old values
for
(
name
in
options
)
{
elem
.
style
[
name
]
=
old
[
name
];
}
return
ret
;
}
});
...
...
src/support.js
View file @
df7847bc
...
...
@@ -176,10 +176,15 @@ jQuery.support = (function( support ) {
// Check if empty table cells still have offsetWidth/Height
support
.
reliableHiddenOffsets
=
isSupported
&&
(
tds
[
0
].
offsetHeight
===
0
);
// Check box-sizing and margin behavior
// Check box-sizing and margin behavior
.
div
.
innerHTML
=
""
;
div
.
style
.
cssText
=
"box-sizing:border-box;-moz-box-sizing:border-box;-webkit-box-sizing:border-box;padding:1px;border:1px;display:block;width:4px;margin-top:1%;position:absolute;top:1%;"
;
support
.
boxSizing
=
(
div
.
offsetWidth
===
4
);
// Workaround failing boxSizing test due to offsetWidth returning wrong value
// with some non-1 values of body zoom, ticket #13543
jQuery
.
swap
(
body
,
body
.
style
.
zoom
!=
null
?
{
zoom
:
1
}
:
{},
function
()
{
support
.
boxSizing
=
div
.
offsetWidth
===
4
;
});
// Use window.getComputedStyle because jsdom on node.js will break without it.
if
(
window
.
getComputedStyle
)
{
...
...
test/data/support/boxSizing.html
0 → 100644
View file @
df7847bc
<!DOCTYPE html>
<html>
<head>
<meta
charset=
"utf-8"
>
<style>
body
{
zoom
:
0.87
;
}
</style>
</head>
<body>
<script
src=
"../../jquery.js"
></script>
<script>
jQuery
(
function
()
{
window
.
parent
.
iframeCallback
(
jQuery
.
support
.
boxSizing
);
});
</script>
</body>
</html>
test/unit/support.js
View file @
df7847bc
...
...
@@ -28,6 +28,11 @@ if ( jQuery.css ) {
});
}
testIframeWithCallback
(
"A non-1 zoom on body doesn't cause WebKit to fail box-sizing test"
,
"support/boxSizing.html"
,
function
(
boxSizing
)
{
expect
(
1
);
equal
(
boxSizing
,
jQuery
.
support
.
boxSizing
,
"box-sizing properly detected on page with non-1 body zoom"
);
});
testIframeWithCallback
(
"A background on the testElement does not cause IE8 to crash (#9823)"
,
"support/testElementCrash.html"
,
function
()
{
expect
(
1
);
ok
(
true
,
"IE8 does not crash"
);
...
...
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