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
299cccde
Commit
299cccde
authored
Oct 31, 2011
by
timmywil
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Construct a new container so that styles on the body are not affected
parent
93750cee
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
8 deletions
+14
-8
support.js
src/support.js
+14
-8
No files found.
src/support.js
View file @
299cccde
...
@@ -256,22 +256,25 @@ jQuery.support = (function() {
...
@@ -256,22 +256,25 @@ jQuery.support = (function() {
// related to the invisible body in IE8
// related to the invisible body in IE8
jQuery
(
function
()
{
jQuery
(
function
()
{
var
outer
,
inner
,
table
,
td
,
offsetSupport
,
var
outer
,
inner
,
table
,
td
,
offsetSupport
,
body
MarginTop
=
1
,
con
MarginTop
=
1
,
ptlm
=
"position:absolute;top:0;left:0;width:1px;height:1px;margin:0;"
,
ptlm
=
"position:absolute;top:0;left:0;width:1px;height:1px;margin:0;"
,
style
=
"style='"
+
ptlm
+
"border:5px solid #000;padding:0;'"
,
style
=
"style='"
+
ptlm
+
"border:5px solid #000;padding:0;'"
,
html
=
"<div "
+
style
+
"><div></div></div>"
+
html
=
"<div "
+
style
+
"><div></div></div>"
+
"<table "
+
style
+
" cellpadding='0' cellspacing='0'>"
+
"<table "
+
style
+
" cellpadding='0' cellspacing='0'>"
+
"<tbody><tr><td></td></tr></tbody></table>"
;
"<tbody><tr><td></td></tr></tbody></table>"
;
// Reconstruct a container
body
=
document
.
getElementsByTagName
(
"body"
)[
0
];
body
=
document
.
getElementsByTagName
(
"body"
)[
0
];
container
=
document
.
createElement
(
"div"
);
container
.
style
.
cssText
=
"width:0;height:0;border:0;visibility:hidden;position:static;top:0;marginTop:"
+
conMarginTop
+
"px"
;
body
.
insertBefore
(
container
,
body
.
firstChild
);
// Construct a test element
testElement
=
document
.
createElement
(
"div"
);
testElement
=
document
.
createElement
(
"div"
);
body
.
style
.
position
=
"static"
;
body
.
style
.
top
=
"0px"
;
body
.
style
.
marginTop
=
bodyMarginTop
+
"px"
;
testElement
.
style
.
cssText
=
ptlm
+
"border:0;visibility:hidden"
;
testElement
.
style
.
cssText
=
ptlm
+
"border:0;visibility:hidden"
;
testElement
.
innerHTML
=
html
;
testElement
.
innerHTML
=
html
;
body
.
appendChild
(
testElement
);
container
.
appendChild
(
testElement
);
outer
=
testElement
.
firstChild
;
outer
=
testElement
.
firstChild
;
inner
=
outer
.
firstChild
;
inner
=
outer
.
firstChild
;
td
=
outer
.
nextSibling
.
firstChild
.
firstChild
.
firstChild
;
td
=
outer
.
nextSibling
.
firstChild
.
firstChild
.
firstChild
;
...
@@ -292,9 +295,12 @@ jQuery.support = (function() {
...
@@ -292,9 +295,12 @@ jQuery.support = (function() {
outer
.
style
.
position
=
"relative"
;
outer
.
style
.
position
=
"relative"
;
offsetSupport
.
subtractsBorderForOverflowNotVisible
=
(
inner
.
offsetTop
===
-
5
);
offsetSupport
.
subtractsBorderForOverflowNotVisible
=
(
inner
.
offsetTop
===
-
5
);
offsetSupport
.
doesNotIncludeMarginInBodyOffset
=
(
body
.
offsetTop
!==
bodyMarginTop
);
offsetSupport
.
doesNotIncludeMarginInBodyOffset
=
(
body
.
offsetTop
!==
conMarginTop
);
body
.
removeChild
(
container
);
testElement
=
container
=
null
;
body
.
removeChild
(
testElement
);
// Extend both jQuery.offset and jQuery.support
jQuery
.
extend
(
jQuery
.
offset
,
offsetSupport
);
jQuery
.
extend
(
jQuery
.
offset
,
offsetSupport
);
jQuery
.
extend
(
support
,
offsetSupport
);
jQuery
.
extend
(
support
,
offsetSupport
);
});
});
...
@@ -303,7 +309,7 @@ jQuery.support = (function() {
...
@@ -303,7 +309,7 @@ jQuery.support = (function() {
testElementParent
.
removeChild
(
testElement
);
testElementParent
.
removeChild
(
testElement
);
// Null connected elements to avoid leaks in IE
// Null connected elements to avoid leaks in IE
testElement
=
fragment
=
select
=
opt
=
body
=
marginDiv
=
div
=
input
=
null
;
fragment
=
select
=
opt
=
body
=
marginDiv
=
div
=
input
=
null
;
return
support
;
return
support
;
})();
})();
...
...
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