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
c78a3ba6
Commit
c78a3ba6
authored
Oct 22, 2012
by
yiminghe
Committed by
Dave Methvin
Oct 30, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #12685. Handle inconsistent opacity for ie < 9. Close gh-1005.
parent
bea5ecbb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
4 deletions
+23
-4
AUTHORS.txt
AUTHORS.txt
+1
-0
css.js
src/css.js
+6
-4
css.js
test/unit/css.js
+16
-0
No files found.
AUTHORS.txt
View file @
c78a3ba6
...
...
@@ -153,3 +153,4 @@ Jay Merrifield <fracmak@gmail.com>
Allen J Schmidt Jr <cobrasoft@gmail.com>
Marcel Greter <marcel.greter@ocbnet.ch>
Matthias Jäggli <matthias.jaeggli@gmail.com>
Yiming He <yiminghe@gmail.com>
src/css.js
View file @
c78a3ba6
var
curCSS
,
iframe
,
iframeDoc
,
ralpha
=
/alpha
\([^
)
]
*
\)
/i
,
ropacity
=
/opacity
=
([^
)
]
*
)
/
,
ropacity
=
/opacity
\s
*=
\s
*
([^
)
]
*
)
/
,
rposition
=
/^
(
top|right|bottom|left
)
$/
,
// swappable if display is none or starts with table except "table", "table-cell", or "table-caption"
// see here for display values: https://developer.mozilla.org/en-US/docs/CSS/display
...
...
@@ -535,7 +535,9 @@ if ( !jQuery.support.opacity ) {
style
.
zoom
=
1
;
// if setting opacity to 1, and no other filters exist - attempt to remove filter attribute #6652
if
(
value
>=
1
&&
jQuery
.
trim
(
filter
.
replace
(
ralpha
,
""
)
)
===
""
&&
// if value === "", then remove inline opacity #12685
if
(
(
value
>=
1
||
value
===
""
)
&&
jQuery
.
trim
(
filter
.
replace
(
ralpha
,
""
)
)
===
""
&&
style
.
removeAttribute
)
{
// Setting style.filter to null, "" & " " still leave "filter:" in the cssText
...
...
@@ -543,8 +545,8 @@ if ( !jQuery.support.opacity ) {
// style.removeAttribute is IE Only, but so apparently is this code path...
style
.
removeAttribute
(
"filter"
);
// if there
there is no filter style applied in a css rule
, we are done
if
(
currentStyle
&&
!
currentStyle
.
filter
)
{
// if there
is no filter style applied in a css rule or unset inline opacity
, we are done
if
(
value
===
""
||
currentStyle
&&
!
currentStyle
.
filter
)
{
return
;
}
}
...
...
test/unit/css.js
View file @
c78a3ba6
...
...
@@ -868,4 +868,20 @@ test( "cssHooks - expand", function() {
});
test
(
"css opacity consistency across browsers (#12685)"
,
function
()
{
expect
(
4
);
var
fixture
=
jQuery
(
"#qunit-fixture"
),
style
=
jQuery
(
"<style>.opacityWithSpaces_t12685 { opacity: 0.1; filter: alpha(opacity = 10); } .opacityNoSpaces_t12685 { opacity: 0.2; filter: alpha(opacity=20); }</style>"
).
appendTo
(
fixture
),
el
=
jQuery
(
"<div class='opacityWithSpaces_t12685'></div>"
).
appendTo
(
fixture
);
equal
(
Math
.
round
(
el
.
css
(
"opacity"
)
*
100
),
10
,
"opacity from style sheet (filter:alpha with spaces)"
);
el
.
removeClass
(
"opacityWithSpaces_t12685"
).
addClass
(
"opacityNoSpaces_t12685"
);
equal
(
Math
.
round
(
el
.
css
(
"opacity"
)
*
100
),
20
,
"opacity from style sheet (filter:alpha without spaces)"
);
el
.
css
(
"opacity"
,
0.3
);
equal
(
Math
.
round
(
el
.
css
(
"opacity"
)
*
100
),
30
,
"override opacity"
);
el
.
css
(
"opacity"
,
""
);
equal
(
Math
.
round
(
el
.
css
(
"opacity"
)
*
100
),
20
,
"remove opacity override"
);
});
}
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