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
b96522ac
Commit
b96522ac
authored
Feb 14, 2014
by
Richard Gibson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Support: Reduce size via code consolidation and minification awareness
Ref
badcd1b6
Closes gh-1518
parent
f361f037
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
116 additions
and
196 deletions
+116
-196
support.js
src/attributes/support.js
+3
-5
support.js
src/css/support.js
+65
-110
support.js
src/effects/support.js
+33
-59
support.js
src/manipulation/support.js
+5
-8
support.js
src/support.js
+10
-14
No files found.
src/attributes/support.js
View file @
b96522ac
...
@@ -3,10 +3,11 @@ define([
...
@@ -3,10 +3,11 @@ define([
],
function
(
support
)
{
],
function
(
support
)
{
(
function
()
{
(
function
()
{
var
a
,
input
,
select
,
opt
,
// Minified: var a,b,c,d,e
div
=
document
.
createElement
(
"div"
)
;
var
input
,
div
,
select
,
a
,
opt
;
// Setup
// Setup
div
=
document
.
createElement
(
"div"
);
div
.
setAttribute
(
"className"
,
"t"
);
div
.
setAttribute
(
"className"
,
"t"
);
div
.
innerHTML
=
" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"
;
div
.
innerHTML
=
" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"
;
a
=
div
.
getElementsByTagName
(
"a"
)[
0
];
a
=
div
.
getElementsByTagName
(
"a"
)[
0
];
...
@@ -54,9 +55,6 @@ define([
...
@@ -54,9 +55,6 @@ define([
input
.
value
=
"t"
;
input
.
value
=
"t"
;
input
.
setAttribute
(
"type"
,
"radio"
);
input
.
setAttribute
(
"type"
,
"radio"
);
support
.
radioValue
=
input
.
value
===
"t"
;
support
.
radioValue
=
input
.
value
===
"t"
;
// Null elements to avoid leaks in IE.
a
=
input
=
select
=
opt
=
div
=
null
;
})();
})();
return
support
;
return
support
;
...
...
src/css/support.js
View file @
b96522ac
...
@@ -4,89 +4,40 @@ define([
...
@@ -4,89 +4,40 @@ define([
],
function
(
jQuery
,
support
)
{
],
function
(
jQuery
,
support
)
{
(
function
()
{
(
function
()
{
var
a
,
reliableHiddenOffsetsVal
,
boxSizingVal
,
boxSizingReliableVal
,
// Minified: var b,c,d,e,f,g, h,i
pixelPositionVal
,
var
div
,
style
,
a
,
pixelPositionVal
,
boxSizingVal
,
boxSizingReliableVal
,
div
=
document
.
createElement
(
"div"
),
reliableHiddenOffsetsVal
,
reliableMarginRightVal
;
containerStyles
=
"border:0;width:0;height:0;position:absolute;top:0;left:-9999px"
,
// Support: Firefox<29, Android 2.3 (Prefixed box-sizing versions).
divReset
=
"-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;"
+
"display:block;padding:0;margin:0;border:0"
;
// Setup
// Setup
div
=
document
.
createElement
(
"div"
);
div
.
innerHTML
=
" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"
;
div
.
innerHTML
=
" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"
;
a
=
div
.
getElementsByTagName
(
"a"
)[
0
];
a
=
div
.
getElementsByTagName
(
"a"
)[
0
];
style
=
a
&&
a
.
style
;
// Finish early in limited (non-browser) environments
// Finish early in limited (non-browser) environments
if
(
!
a
||
!
a
.
style
)
{
if
(
!
style
)
{
return
;
return
;
}
}
a
.
style
.
cssText
=
"float:left;opacity:.5"
;
style
.
cssText
=
"float:left;opacity:.5"
;
// Support: IE<9
// Support: IE<9
// Make sure that element opacity exists (as opposed to filter)
// Make sure that element opacity exists (as opposed to filter)
support
.
opacity
=
a
.
style
.
opacity
===
"0.5"
;
support
.
opacity
=
style
.
opacity
===
"0.5"
;
// Verify style float existence
// Verify style float existence
// (IE uses styleFloat instead of cssFloat)
// (IE uses styleFloat instead of cssFloat)
support
.
cssFloat
=
!!
a
.
style
.
cssFloat
;
support
.
cssFloat
=
!!
style
.
cssFloat
;
div
.
style
.
backgroundClip
=
"content-box"
;
div
.
style
.
backgroundClip
=
"content-box"
;
div
.
cloneNode
(
true
).
style
.
backgroundClip
=
""
;
div
.
cloneNode
(
true
).
style
.
backgroundClip
=
""
;
support
.
clearCloneStyle
=
div
.
style
.
backgroundClip
===
"content-box"
;
support
.
clearCloneStyle
=
div
.
style
.
backgroundClip
===
"content-box"
;
// Null elements to avoid leaks in IE.
a
=
div
=
null
;
jQuery
.
extend
(
support
,
{
jQuery
.
extend
(
support
,
{
reliableHiddenOffsets
:
function
()
{
reliableHiddenOffsets
:
function
()
{
if
(
reliableHiddenOffsetsVal
!=
null
)
{
if
(
reliableHiddenOffsetsVal
==
null
)
{
return
reliableHiddenOffsetsVal
;
computeStyleTests
();
}
var
container
,
tds
,
isSupported
,
div
=
document
.
createElement
(
"div"
),
body
=
document
.
getElementsByTagName
(
"body"
)[
0
];
if
(
!
body
)
{
// Return for frameset docs that don't have a body
return
;
}
}
// Setup
div
.
setAttribute
(
"className"
,
"t"
);
div
.
innerHTML
=
" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"
;
container
=
document
.
createElement
(
"div"
);
container
.
style
.
cssText
=
containerStyles
;
body
.
appendChild
(
container
).
appendChild
(
div
);
// Support: IE8
// Check if table cells still have offsetWidth/Height when they are set
// to display:none and there are still other visible table cells in a
// table row; if so, offsetWidth/Height are not reliable for use when
// determining if an element has been hidden directly using
// display:none (it is still safe to use offsets if a parent element is
// hidden; don safety goggles and see bug #4512 for more information).
div
.
innerHTML
=
"<table><tr><td></td><td>t</td></tr></table>"
;
tds
=
div
.
getElementsByTagName
(
"td"
);
tds
[
0
].
style
.
cssText
=
"padding:0;margin:0;border:0;display:none"
;
isSupported
=
(
tds
[
0
].
offsetHeight
===
0
);
tds
[
0
].
style
.
display
=
""
;
tds
[
1
].
style
.
display
=
"none"
;
// Support: IE8
// Check if empty table cells still have offsetWidth/Height
reliableHiddenOffsetsVal
=
isSupported
&&
(
tds
[
0
].
offsetHeight
===
0
);
body
.
removeChild
(
container
);
// Null elements to avoid leaks in IE.
div
=
body
=
null
;
return
reliableHiddenOffsetsVal
;
return
reliableHiddenOffsetsVal
;
},
},
...
@@ -113,65 +64,35 @@ define([
...
@@ -113,65 +64,35 @@ define([
// Support: Android 2.3
// Support: Android 2.3
reliableMarginRight
:
function
()
{
reliableMarginRight
:
function
()
{
var
body
,
container
,
div
,
marginDiv
,
if
(
reliableMarginRightVal
==
null
)
{
// Support: IE<9.
computeStyleTests
();
// IE should pass the test but we're using getComputedStyle
// to compute it so just return true if the method is not present.
reliableMarginRightVal
=
true
;
// Use window.getComputedStyle because jsdom on node.js will break without it.
if
(
window
.
getComputedStyle
)
{
body
=
document
.
getElementsByTagName
(
"body"
)[
0
];
if
(
!
body
)
{
// Test fired too early or in an unsupported environment, exit.
return
;
}
container
=
document
.
createElement
(
"div"
);
div
=
document
.
createElement
(
"div"
);
container
.
style
.
cssText
=
containerStyles
;
body
.
appendChild
(
container
).
appendChild
(
div
);
// Check if div with explicit width and no margin-right incorrectly
// gets computed margin-right based on width of container. (#3333)
// Fails in WebKit before Feb 2011 nightlies
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
marginDiv
=
div
.
appendChild
(
document
.
createElement
(
"div"
)
);
marginDiv
.
style
.
cssText
=
div
.
style
.
cssText
=
divReset
;
marginDiv
.
style
.
marginRight
=
marginDiv
.
style
.
width
=
"0"
;
div
.
style
.
width
=
"1px"
;
reliableMarginRightVal
=
!
parseFloat
(
(
window
.
getComputedStyle
(
marginDiv
,
null
)
||
{}
).
marginRight
);
body
.
removeChild
(
container
);
}
}
return
reliableMarginRightVal
;
return
reliableMarginRightVal
;
}
}
});
});
function
computeStyleTests
()
{
function
computeStyleTests
()
{
var
container
,
div
,
// Minified: var b,c,d,j
body
=
document
.
getElementsByTagName
(
"body"
)[
0
]
;
var
div
,
body
,
container
,
contents
;
if
(
!
body
)
{
body
=
document
.
getElementsByTagName
(
"body"
)[
0
];
if
(
!
body
||
!
body
.
style
)
{
// Test fired too early or in an unsupported environment, exit.
// Test fired too early or in an unsupported environment, exit.
return
;
return
;
}
}
container
=
document
.
createElement
(
"div"
);
// Setup
div
=
document
.
createElement
(
"div"
);
div
=
document
.
createElement
(
"div"
);
container
.
style
.
cssText
=
containerStyles
;
container
=
document
.
createElement
(
"div"
)
;
container
.
style
.
cssText
=
"position:absolute;border:0;width:0;height:0;top:0;left:-9999px"
;
body
.
appendChild
(
container
).
appendChild
(
div
);
body
.
appendChild
(
container
).
appendChild
(
div
);
// Support: Firefox<29, Android 2.3 (Prefixed box-sizing versions).
div
.
style
.
cssText
=
div
.
style
.
cssText
=
"-webkit-box-sizing:border-box;-moz-box-sizing:border-box;box-sizing:border-box;"
+
// Support: Firefox<29, Android 2.3
"position:absolute;display:block;padding:1px;border:1px;width:4px;"
+
// Vendor-prefix box-sizing
"margin-top:1%;top:1%"
;
"-webkit-box-sizing:border-box;-moz-box-sizing:border-box;"
+
"box-sizing:border-box;display:block;margin-top:1%;top:1%;"
+
"border:1px;padding:1px;width:4px;position:absolute"
;
// Workaround failing boxSizing test due to offsetWidth returning wrong value
// Workaround failing boxSizing test due to offsetWidth returning wrong value
// with some non-1 values of body zoom, ticket #13543
// with some non-1 values of body zoom, ticket #13543
...
@@ -179,21 +100,55 @@ define([
...
@@ -179,21 +100,55 @@ define([
boxSizingVal
=
div
.
offsetWidth
===
4
;
boxSizingVal
=
div
.
offsetWidth
===
4
;
});
});
//
Will be changed later if needed.
//
Support: IE<9
boxSizingReliableVal
=
true
;
// Assume reasonable values in the absence of getComputedStyle
pixelPositionVal
=
false
;
pixelPositionVal
=
false
;
reliableMarginRightVal
=
boxSizingReliableVal
=
true
;
// Use window.getComputedStyle because jsdom on node.js will break without it.
// Support: node.js jsdom
// Don't assume that getComputedStyle is a property of the global object
if
(
window
.
getComputedStyle
)
{
if
(
window
.
getComputedStyle
)
{
pixelPositionVal
=
(
window
.
getComputedStyle
(
div
,
null
)
||
{}
).
top
!==
"1%"
;
pixelPositionVal
=
(
window
.
getComputedStyle
(
div
,
null
)
||
{}
).
top
!==
"1%"
;
boxSizingReliableVal
=
boxSizingReliableVal
=
(
window
.
getComputedStyle
(
div
,
null
)
||
{
width
:
"4px"
}
).
width
===
"4px"
;
(
window
.
getComputedStyle
(
div
,
null
)
||
{
width
:
"4px"
}
).
width
===
"4px"
;
// Support: Android 2.3
// Div with explicit width and no margin-right incorrectly
// gets computed margin-right based on width of container (#3333)
// WebKit Bug 13343 - getComputedStyle returns wrong value for margin-right
contents
=
div
.
appendChild
(
document
.
createElement
(
"div"
)
);
// Reset CSS: box-sizing; display; margin; border; padding
contents
.
style
.
cssText
=
div
.
style
.
cssText
=
// Support: Firefox<29, Android 2.3
// Vendor-prefix box-sizing
"-webkit-box-sizing:content-box;-moz-box-sizing:content-box;"
+
"box-sizing:content-box;display:block;margin:0;border:0;padding:0"
;
contents
.
style
.
marginRight
=
contents
.
style
.
width
=
"0"
;
div
.
style
.
width
=
"1px"
;
reliableMarginRightVal
=
!
parseFloat
(
(
window
.
getComputedStyle
(
contents
,
null
)
||
{}
).
marginRight
);
}
}
body
.
removeChild
(
container
);
// Support: IE8
// Check if table cells still have offsetWidth/Height when they are set
// to display:none and there are still other visible table cells in a
// table row; if so, offsetWidth/Height are not reliable for use when
// determining if an element has been hidden directly using
// display:none (it is still safe to use offsets if a parent element is
// hidden; don safety goggles and see bug #4512 for more information).
div
.
innerHTML
=
"<table><tr><td></td><td>t</td></tr></table>"
;
contents
=
div
.
getElementsByTagName
(
"td"
);
contents
[
0
].
style
.
cssText
=
"margin:0;border:0;padding:0;display:none"
;
reliableHiddenOffsetsVal
=
contents
[
0
].
offsetHeight
===
0
;
if
(
reliableHiddenOffsetsVal
)
{
contents
[
0
].
style
.
display
=
""
;
contents
[
1
].
style
.
display
=
"none"
;
reliableHiddenOffsetsVal
=
contents
[
0
].
offsetHeight
===
0
;
}
// Null elements to avoid leaks in IE.
body
.
removeChild
(
container
);
div
=
body
=
null
;
}
}
})();
})();
...
...
src/effects/support.js
View file @
b96522ac
...
@@ -4,73 +4,47 @@ define([
...
@@ -4,73 +4,47 @@ define([
],
function
(
strundefined
,
support
)
{
],
function
(
strundefined
,
support
)
{
(
function
()
{
(
function
()
{
var
a
,
shrinkWrapBlocksVal
,
var
shrinkWrapBlocksVal
;
div
=
document
.
createElement
(
"div"
),
// Support: Firefox<29, Android 2.3 (Prefixed box-sizing versions).
divReset
=
"-webkit-box-sizing:content-box;-moz-box-sizing:content-box;box-sizing:content-box;"
+
"display:block;padding:0;margin:0;border:0"
;
// Setup
div
.
innerHTML
=
" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"
;
a
=
div
.
getElementsByTagName
(
"a"
)[
0
];
// Finish early in limited (non-browser) environments
if
(
!
a
||
!
a
.
style
)
{
return
;
}
a
.
style
.
cssText
=
"float:left;opacity:.5"
;
// Support: IE<9
// Make sure that element opacity exists (as opposed to filter)
support
.
opacity
=
a
.
style
.
opacity
===
"0.5"
;
// Verify style float existence
// (IE uses styleFloat instead of cssFloat)
support
.
cssFloat
=
!!
a
.
style
.
cssFloat
;
div
.
style
.
backgroundClip
=
"content-box"
;
div
.
cloneNode
(
true
).
style
.
backgroundClip
=
""
;
support
.
clearCloneStyle
=
div
.
style
.
backgroundClip
===
"content-box"
;
// Null elements to avoid leaks in IE.
a
=
div
=
null
;
support
.
shrinkWrapBlocks
=
function
()
{
support
.
shrinkWrapBlocks
=
function
()
{
var
body
,
container
,
div
,
containerStyles
;
if
(
shrinkWrapBlocksVal
!=
null
)
{
return
shrinkWrapBlocksVal
;
if
(
shrinkWrapBlocksVal
==
null
)
{
}
body
=
document
.
getElementsByTagName
(
"body"
)[
0
];
if
(
!
body
)
{
// Test fired too early or in an unsupported environment, exit.
return
;
}
containerStyles
=
"border:0;width:0;height:0;position:absolute;top:0;left:-9999px"
;
container
=
document
.
createElement
(
"div"
);
div
=
document
.
createElement
(
"div"
);
body
.
appendChild
(
container
).
appendChild
(
div
);
// Will be changed later if needed.
// Will be changed later if needed.
shrinkWrapBlocksVal
=
false
;
shrinkWrapBlocksVal
=
false
;
if
(
typeof
div
.
style
.
zoom
!==
strundefined
)
{
// Minified: var b,c,d
// Support: IE6
var
div
,
body
,
container
;
// Check if elements with layout shrink-wrap their children
div
.
style
.
cssText
=
divReset
+
";width:1px;padding:1px;zoom:1"
;
div
.
innerHTML
=
"<div></div>"
;
div
.
firstChild
.
style
.
width
=
"5px"
;
shrinkWrapBlocksVal
=
div
.
offsetWidth
!==
3
;
}
body
.
removeChild
(
container
);
body
=
document
.
getElementsByTagName
(
"body"
)[
0
];
if
(
!
body
||
!
body
.
style
)
{
// Test fired too early or in an unsupported environment, exit.
return
;
}
// Null elements to avoid leaks in IE.
// Setup
body
=
container
=
div
=
null
;
div
=
document
.
createElement
(
"div"
);
container
=
document
.
createElement
(
"div"
);
container
.
style
.
cssText
=
"position:absolute;border:0;width:0;height:0;top:0;left:-9999px"
;
body
.
appendChild
(
container
).
appendChild
(
div
);
// Support: IE6
// Check if elements with layout shrink-wrap their children
if
(
typeof
div
.
style
.
zoom
!==
strundefined
)
{
// Reset CSS: box-sizing; display; margin; border
div
.
style
.
cssText
=
// Support: Firefox<29, Android 2.3
// Vendor-prefix box-sizing
"-webkit-box-sizing:content-box;-moz-box-sizing:content-box;"
+
"box-sizing:content-box;display:block;margin:0;border:0;"
+
"padding:1px;width:1px;zoom:1"
;
div
.
appendChild
(
document
.
createElement
(
"div"
)
).
style
.
width
=
"5px"
;
shrinkWrapBlocksVal
=
div
.
offsetWidth
!==
3
;
}
}
body
.
removeChild
(
container
);
return
shrinkWrapBlocksVal
;
return
shrinkWrapBlocksVal
;
};
};
...
...
src/manipulation/support.js
View file @
b96522ac
...
@@ -3,13 +3,13 @@ define([
...
@@ -3,13 +3,13 @@ define([
],
function
(
support
)
{
],
function
(
support
)
{
(
function
()
{
(
function
()
{
var
fragment
=
document
.
createDocumentFragment
(),
// Minified: var a,b,c
div
=
document
.
createElement
(
"div"
),
var
input
=
document
.
createElement
(
"input"
),
input
=
document
.
createElement
(
"input"
);
div
=
document
.
createElement
(
"div"
),
fragment
=
document
.
createDocumentFragment
();
// Setup
// Setup
div
.
setAttribute
(
"className"
,
"t"
);
div
.
innerHTML
=
" <link/><table></table><a href='/a'>a</a><input type='checkbox'/>"
;
div
.
innerHTML
=
" <link/><table></table><a href='/a'>a</a>"
;
// IE strips leading whitespace when .innerHTML is used
// IE strips leading whitespace when .innerHTML is used
support
.
leadingWhitespace
=
div
.
firstChild
.
nodeType
===
3
;
support
.
leadingWhitespace
=
div
.
firstChild
.
nodeType
===
3
;
...
@@ -69,9 +69,6 @@ define([
...
@@ -69,9 +69,6 @@ define([
support
.
deleteExpando
=
false
;
support
.
deleteExpando
=
false
;
}
}
}
}
// Null elements to avoid leaks in IE.
fragment
=
div
=
input
=
null
;
})();
})();
return
support
;
return
support
;
...
...
src/support.js
View file @
b96522ac
...
@@ -19,23 +19,21 @@ support.ownLast = i !== "0";
...
@@ -19,23 +19,21 @@ support.ownLast = i !== "0";
// false until the test is run
// false until the test is run
support
.
inlineBlockNeedsLayout
=
false
;
support
.
inlineBlockNeedsLayout
=
false
;
// Execute ASAP in case we need to set body.style.zoom
jQuery
(
function
()
{
jQuery
(
function
()
{
//
We need to execute this one support test ASAP because we need to know
//
Minified: var a,b,c,d
// if body.style.zoom needs to be set.
var
val
,
div
,
body
,
container
;
var
container
,
div
,
body
=
document
.
getElementsByTagName
(
"body"
)[
0
];
body
=
document
.
getElementsByTagName
(
"body"
)[
0
];
if
(
!
body
||
!
body
.
style
)
{
if
(
!
body
)
{
// Return for frameset docs that don't have a body
// Return for frameset docs that don't have a body
return
;
return
;
}
}
// Setup
// Setup
container
=
document
.
createElement
(
"div"
);
container
.
style
.
cssText
=
"border:0;width:0;height:0;position:absolute;top:0;left:-9999px;margin-top:1px"
;
div
=
document
.
createElement
(
"div"
);
div
=
document
.
createElement
(
"div"
);
container
=
document
.
createElement
(
"div"
);
container
.
style
.
cssText
=
"position:absolute;border:0;width:0;height:0;top:0;left:-9999px"
;
body
.
appendChild
(
container
).
appendChild
(
div
);
body
.
appendChild
(
container
).
appendChild
(
div
);
if
(
typeof
div
.
style
.
zoom
!==
strundefined
)
{
if
(
typeof
div
.
style
.
zoom
!==
strundefined
)
{
...
@@ -43,9 +41,10 @@ jQuery(function() {
...
@@ -43,9 +41,10 @@ jQuery(function() {
// Check if natively block-level elements act like inline-block
// Check if natively block-level elements act like inline-block
// elements when setting their display to 'inline' and giving
// elements when setting their display to 'inline' and giving
// them layout
// them layout
div
.
style
.
cssText
=
"
border:0;margin:0;width:1px;padding:1px;display:inline
;zoom:1"
;
div
.
style
.
cssText
=
"
display:inline;margin:0;border:0;padding:1px;width:1px
;zoom:1"
;
if
(
(
support
.
inlineBlockNeedsLayout
=
(
div
.
offsetWidth
===
3
))
)
{
support
.
inlineBlockNeedsLayout
=
val
=
div
.
offsetWidth
===
3
;
if
(
val
)
{
// Prevent IE 6 from affecting layout for positioned elements #11048
// Prevent IE 6 from affecting layout for positioned elements #11048
// Prevent IE from shrinking the body in IE 7 mode #12869
// Prevent IE from shrinking the body in IE 7 mode #12869
// Support: IE<8
// Support: IE<8
...
@@ -54,9 +53,6 @@ jQuery(function() {
...
@@ -54,9 +53,6 @@ jQuery(function() {
}
}
body
.
removeChild
(
container
);
body
.
removeChild
(
container
);
// Null elements to avoid leaks in IE
container
=
div
=
null
;
});
});
});
});
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