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
bea5ecbb
Commit
bea5ecbb
authored
Sep 28, 2012
by
Oleg
Committed by
Dave Methvin
Oct 29, 2012
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix #10416. Don't trust computed styles on detached elements. Close gh-941.
parent
5be4c10c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
21 additions
and
13 deletions
+21
-13
css.js
src/css.js
+6
-8
css.js
test/unit/css.js
+15
-5
No files found.
src/css.js
View file @
bea5ecbb
...
@@ -44,12 +44,14 @@ function vendorPropName( style, name ) {
...
@@ -44,12 +44,14 @@ function vendorPropName( style, name ) {
}
}
function
isHidden
(
elem
,
el
)
{
function
isHidden
(
elem
,
el
)
{
// isHidden might be called from jQuery#filter function;
// in that case, element will be second argument
elem
=
el
||
elem
;
elem
=
el
||
elem
;
return
jQuery
.
css
(
elem
,
"display"
)
===
"none"
||
!
jQuery
.
contains
(
elem
.
ownerDocument
,
elem
);
return
curCSS
(
elem
,
"display"
)
===
"none"
||
!
jQuery
.
contains
(
elem
.
ownerDocument
,
elem
);
}
}
function
showHide
(
elements
,
show
)
{
function
showHide
(
elements
,
show
)
{
var
elem
,
display
,
var
elem
,
values
=
[],
values
=
[],
index
=
0
,
index
=
0
,
length
=
elements
.
length
;
length
=
elements
.
length
;
...
@@ -73,12 +75,8 @@ function showHide( elements, show ) {
...
@@ -73,12 +75,8 @@ function showHide( elements, show ) {
if
(
elem
.
style
.
display
===
""
&&
isHidden
(
elem
)
)
{
if
(
elem
.
style
.
display
===
""
&&
isHidden
(
elem
)
)
{
values
[
index
]
=
jQuery
.
_data
(
elem
,
"olddisplay"
,
css_defaultDisplay
(
elem
.
nodeName
)
);
values
[
index
]
=
jQuery
.
_data
(
elem
,
"olddisplay"
,
css_defaultDisplay
(
elem
.
nodeName
)
);
}
}
}
else
{
}
else
if
(
!
values
[
index
]
&&
!
isHidden
(
elem
)
)
{
display
=
curCSS
(
elem
,
"display"
);
jQuery
.
_data
(
elem
,
"olddisplay"
,
curCSS
(
elem
,
"display"
)
);
if
(
!
values
[
index
]
&&
display
!==
"none"
)
{
jQuery
.
_data
(
elem
,
"olddisplay"
,
display
);
}
}
}
}
}
...
...
test/unit/css.js
View file @
bea5ecbb
...
@@ -504,12 +504,10 @@ test("show() resolves correct default display #8099", function() {
...
@@ -504,12 +504,10 @@ test("show() resolves correct default display #8099", function() {
dfn8099
.
remove
();
dfn8099
.
remove
();
});
});
test
(
"show() resolves correct default display, detached nodes (#10006)"
,
function
(){
test
(
"show() resolves correct default display for detached nodes"
,
function
(){
// Tests originally contributed by Orkel in
expect
(
13
);
// https://github.com/jquery/jquery/pull/458
expect
(
11
);
var
div
,
span
;
var
div
,
span
,
tr
,
trDisplay
;
div
=
jQuery
(
"<div class='hidden'>"
);
div
=
jQuery
(
"<div class='hidden'>"
);
div
.
show
().
appendTo
(
"#qunit-fixture"
);
div
.
show
().
appendTo
(
"#qunit-fixture"
);
...
@@ -559,6 +557,18 @@ test( "show() resolves correct default display, detached nodes (#10006)", functi
...
@@ -559,6 +557,18 @@ test( "show() resolves correct default display, detached nodes (#10006)", functi
div
.
show
().
appendTo
(
"#qunit-fixture"
);
div
.
show
().
appendTo
(
"#qunit-fixture"
);
equal
(
div
.
css
(
"display"
),
"inline"
,
"Make sure that element has same display when it was created."
);
equal
(
div
.
css
(
"display"
),
"inline"
,
"Make sure that element has same display when it was created."
);
div
.
remove
();
div
.
remove
();
tr
=
jQuery
(
"<tr/>"
);
jQuery
(
"#table"
).
append
(
tr
);
trDisplay
=
tr
.
css
(
"display"
);
tr
.
detach
().
hide
().
show
();
equal
(
tr
[
0
].
style
.
display
,
trDisplay
,
"For detached tr elements, display should always be like for attached trs"
);
tr
.
remove
();
span
=
span
=
jQuery
(
"<span/>"
).
hide
().
show
();
equal
(
span
[
0
].
style
.
display
,
"inline"
,
"For detached span elements, display should always be inline"
);
span
.
remove
();
});
});
test
(
"show() resolves correct default display #10227"
,
function
()
{
test
(
"show() resolves correct default display #10227"
,
function
()
{
...
...
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