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
7f6a9913
Commit
7f6a9913
authored
Dec 07, 2011
by
Mike Sherov
Committed by
Dave Methvin
Dec 07, 2011
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #10639. Make percent-specified margins return px values in WebKit.
parent
2c75a993
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
3 deletions
+27
-3
css.js
src/css.js
+13
-2
support.js
src/support.js
+7
-1
css.js
test/unit/css.js
+7
-0
No files found.
src/css.js
View file @
7f6a9913
...
@@ -7,6 +7,7 @@ var ralpha = /alpha\([^)]*\)/i,
...
@@ -7,6 +7,7 @@ var ralpha = /alpha\([^)]*\)/i,
rnumpx
=
/^-
?\d
+
(?:
px
)?
$/i
,
rnumpx
=
/^-
?\d
+
(?:
px
)?
$/i
,
rnumnopx
=
/^-
?\d
+
(?!
px
)[^\d\s]
+$/i
,
rnumnopx
=
/^-
?\d
+
(?!
px
)[^\d\s]
+$/i
,
rrelNum
=
/^
([\-
+
])
=
([\-
+.
\d
e
]
+
)
/
,
rrelNum
=
/^
([\-
+
])
=
([\-
+.
\d
e
]
+
)
/
,
rmargin
=
/^margin/
,
cssShow
=
{
position
:
"absolute"
,
visibility
:
"hidden"
,
display
:
"block"
},
cssShow
=
{
position
:
"absolute"
,
visibility
:
"hidden"
,
display
:
"block"
},
cssWidth
=
[
"Left"
,
"Right"
],
cssWidth
=
[
"Left"
,
"Right"
],
...
@@ -256,7 +257,7 @@ jQuery(function() {
...
@@ -256,7 +257,7 @@ jQuery(function() {
if
(
document
.
defaultView
&&
document
.
defaultView
.
getComputedStyle
)
{
if
(
document
.
defaultView
&&
document
.
defaultView
.
getComputedStyle
)
{
getComputedStyle
=
function
(
elem
,
name
)
{
getComputedStyle
=
function
(
elem
,
name
)
{
var
ret
,
defaultView
,
computedStyle
;
var
ret
,
defaultView
,
computedStyle
,
width
,
style
=
elem
.
style
;
name
=
name
.
replace
(
rupper
,
"-$1"
).
toLowerCase
();
name
=
name
.
replace
(
rupper
,
"-$1"
).
toLowerCase
();
...
@@ -268,6 +269,16 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {
...
@@ -268,6 +269,16 @@ if ( document.defaultView && document.defaultView.getComputedStyle ) {
}
}
}
}
// A tribute to the "awesome hack by Dean Edwards"
// WebKit uses "computed value (percentage if specified)" instead of "used value" for margins
// which is against the CSSOM draft spec: http://dev.w3.org/csswg/cssom/#resolved-values
if
(
!
jQuery
.
support
.
pixelMargin
&&
computedStyle
&&
rmargin
.
test
(
name
)
&&
rnumnopx
.
test
(
ret
)
)
{
width
=
style
.
width
;
style
.
width
=
ret
;
ret
=
computedStyle
.
width
;
style
.
width
=
width
;
}
return
ret
;
return
ret
;
};
};
}
}
...
@@ -299,7 +310,7 @@ if ( document.documentElement.currentStyle ) {
...
@@ -299,7 +310,7 @@ if ( document.documentElement.currentStyle ) {
if
(
rsLeft
)
{
if
(
rsLeft
)
{
elem
.
runtimeStyle
.
left
=
elem
.
currentStyle
.
left
;
elem
.
runtimeStyle
.
left
=
elem
.
currentStyle
.
left
;
}
}
style
.
left
=
name
===
"fontSize"
?
"1em"
:
(
ret
||
0
)
;
style
.
left
=
name
===
"fontSize"
?
"1em"
:
ret
;
ret
=
style
.
pixelLeft
+
"px"
;
ret
=
style
.
pixelLeft
+
"px"
;
// Revert the changed values
// Revert the changed values
...
...
src/support.js
View file @
7f6a9913
...
@@ -91,7 +91,8 @@ jQuery.support = (function() {
...
@@ -91,7 +91,8 @@ jQuery.support = (function() {
noCloneEvent
:
true
,
noCloneEvent
:
true
,
inlineBlockNeedsLayout
:
false
,
inlineBlockNeedsLayout
:
false
,
shrinkWrapBlocks
:
false
,
shrinkWrapBlocks
:
false
,
reliableMarginRight
:
true
reliableMarginRight
:
true
,
pixelMargin
:
true
};
};
// Make sure checked status is properly cloned
// Make sure checked status is properly cloned
...
@@ -277,6 +278,11 @@ jQuery.support = (function() {
...
@@ -277,6 +278,11 @@ jQuery.support = (function() {
offsetSupport
.
subtractsBorderForOverflowNotVisible
=
(
inner
.
offsetTop
===
-
5
);
offsetSupport
.
subtractsBorderForOverflowNotVisible
=
(
inner
.
offsetTop
===
-
5
);
offsetSupport
.
doesNotIncludeMarginInBodyOffset
=
(
body
.
offsetTop
!==
conMarginTop
);
offsetSupport
.
doesNotIncludeMarginInBodyOffset
=
(
body
.
offsetTop
!==
conMarginTop
);
if
(
window
.
getComputedStyle
)
{
div
.
style
.
marginTop
=
"1%"
;
support
.
pixelMargin
=
(
window
.
getComputedStyle
(
div
,
null
)
||
{
marginTop
:
0
}
).
marginTop
!==
"1%"
;
}
body
.
removeChild
(
container
);
body
.
removeChild
(
container
);
div
=
container
=
null
;
div
=
container
=
null
;
...
...
test/unit/css.js
View file @
7f6a9913
...
@@ -542,4 +542,11 @@ test("Do not append px to 'fill-opacity' #9548", 1, function() {
...
@@ -542,4 +542,11 @@ test("Do not append px to 'fill-opacity' #9548", 1, function() {
equal
(
jQuery
(
this
).
css
(
"fill-opacity"
),
1
,
"Do not append px to 'fill-opacity'"
);
equal
(
jQuery
(
this
).
css
(
"fill-opacity"
),
1
,
"Do not append px to 'fill-opacity'"
);
});
});
});
test
(
"outerWidth(true) and css('margin') returning % instead of px in Webkit, see #10639"
,
function
()
{
var
container
=
jQuery
(
"<div/>"
).
width
(
400
).
appendTo
(
"#qunit-fixture"
),
el
=
jQuery
(
"<div/>"
).
css
({
width
:
"50%"
,
marginRight
:
"50%"
}).
appendTo
(
container
);
equal
(
el
.
outerWidth
(
true
),
400
,
"outerWidth(true) and css('margin') returning % instead of px in Webkit, see #10639"
);
});
});
\ No newline at end of file
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