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
21c0be84
Commit
21c0be84
authored
Apr 17, 2011
by
John Resig
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make sure that hide or show don't fail when operating on non-Element nodes. Fixes #6135.
parent
728a70c0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
15 deletions
+27
-15
effects.js
src/effects.js
+23
-15
effects.js
test/unit/effects.js
+4
-0
No files found.
src/effects.js
View file @
21c0be84
...
@@ -28,19 +28,22 @@ jQuery.fn.extend({
...
@@ -28,19 +28,22 @@ jQuery.fn.extend({
}
else
{
}
else
{
for
(
var
i
=
0
,
j
=
this
.
length
;
i
<
j
;
i
++
)
{
for
(
var
i
=
0
,
j
=
this
.
length
;
i
<
j
;
i
++
)
{
elem
=
this
[
i
];
elem
=
this
[
i
];
display
=
elem
.
style
.
display
;
// Reset the inline display of this element to learn if it is
if
(
elem
.
style
)
{
// being hidden by cascaded rules or not
display
=
elem
.
style
.
display
;
if
(
!
jQuery
.
_data
(
elem
,
"olddisplay"
)
&&
display
===
"none"
)
{
display
=
elem
.
style
.
display
=
""
;
// Reset the inline display of this element to learn if it is
}
// being hidden by cascaded rules or not
if
(
!
jQuery
.
_data
(
elem
,
"olddisplay"
)
&&
display
===
"none"
)
{
display
=
elem
.
style
.
display
=
""
;
}
// Set elements which have been overridden with display: none
// Set elements which have been overridden with display: none
// in a stylesheet to whatever the default browser style is
// in a stylesheet to whatever the default browser style is
// for such an element
// for such an element
if
(
display
===
""
&&
jQuery
.
css
(
elem
,
"display"
)
===
"none"
)
{
if
(
display
===
""
&&
jQuery
.
css
(
elem
,
"display"
)
===
"none"
)
{
jQuery
.
_data
(
elem
,
"olddisplay"
,
defaultDisplay
(
elem
.
nodeName
));
jQuery
.
_data
(
elem
,
"olddisplay"
,
defaultDisplay
(
elem
.
nodeName
));
}
}
}
}
}
...
@@ -48,10 +51,13 @@ jQuery.fn.extend({
...
@@ -48,10 +51,13 @@ jQuery.fn.extend({
// to avoid the constant reflow
// to avoid the constant reflow
for
(
i
=
0
;
i
<
j
;
i
++
)
{
for
(
i
=
0
;
i
<
j
;
i
++
)
{
elem
=
this
[
i
];
elem
=
this
[
i
];
display
=
elem
.
style
.
display
;
if
(
display
===
""
||
display
===
"none"
)
{
if
(
elem
.
style
)
{
elem
.
style
.
display
=
jQuery
.
_data
(
elem
,
"olddisplay"
)
||
""
;
display
=
elem
.
style
.
display
;
if
(
display
===
""
||
display
===
"none"
)
{
elem
.
style
.
display
=
jQuery
.
_data
(
elem
,
"olddisplay"
)
||
""
;
}
}
}
}
}
...
@@ -75,7 +81,9 @@ jQuery.fn.extend({
...
@@ -75,7 +81,9 @@ jQuery.fn.extend({
// Set the display of the elements in a second loop
// Set the display of the elements in a second loop
// to avoid the constant reflow
// to avoid the constant reflow
for
(
i
=
0
;
i
<
j
;
i
++
)
{
for
(
i
=
0
;
i
<
j
;
i
++
)
{
this
[
i
].
style
.
display
=
"none"
;
if
(
this
[
i
].
style
)
{
this
[
i
].
style
.
display
=
"none"
;
}
}
}
return
this
;
return
this
;
...
...
test/unit/effects.js
View file @
21c0be84
...
@@ -88,6 +88,10 @@ test("show()", function() {
...
@@ -88,6 +88,10 @@ test("show()", function() {
var
elem
=
jQuery
(
selector
,
"#show-tests"
).
show
();
var
elem
=
jQuery
(
selector
,
"#show-tests"
).
show
();
equals
(
elem
.
css
(
"display"
),
expected
,
"Show using correct display type for "
+
selector
);
equals
(
elem
.
css
(
"display"
),
expected
,
"Show using correct display type for "
+
selector
);
});
});
// Make sure that showing or hiding a text node doesn't cause an error
jQuery
(
"<div>test</div> text <span>test</span>"
).
show
().
remove
();
jQuery
(
"<div>test</div> text <span>test</span>"
).
hide
().
remove
();
});
});
test
(
"show(Number) - other displays"
,
function
()
{
test
(
"show(Number) - other displays"
,
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