-
Notifications
You must be signed in to change notification settings - Fork 20.6k
CSS: Ignore the CSS cascade in show()/hide()/etc. #2180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
dde0aa8
Effects: Improve comments
gibson042 38f8819
CSS: Ignore the CSS cascade in show()/hide()/etc.
gibson042 f64a6b6
Tests: Replace CSS & Effects #show-tests with inline display: none
gibson042 be3cda1
Tests: Generalize effects assertions from elem.style to jQuery.css
gibson042 e8c6f33
Tests: Avoid using getComputedStyle on disconnected elements
gibson042 6e6eeb6
Tests: Convert an effects test to fake asynchronicitiy
gibson042 dacb47e
Effects: Reset display to inline before finishing a hide animation
gibson042 7b8b177
Tests: Remove "Animation ends immediately when document.hidden"
gibson042 867b24b
Effects: Abandon defaultDisplay
gibson042 f5fdbd0
Effects: Reduce size
gibson042 bda5c2b
Effects: Reference other tickets
gibson042 65d3d4a
CSS: Rename private data key "olddisplay" for smaller size
gibson042 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
define([ | ||
"../data/var/dataPriv" | ||
], function( dataPriv ) { | ||
|
||
function showHide( elements, show ) { | ||
var display, elem, | ||
values = [], | ||
index = 0, | ||
length = elements.length; | ||
|
||
// Determine new display value for elements that need to change | ||
for ( ; index < length; index++ ) { | ||
elem = elements[ index ]; | ||
if ( !elem.style ) { | ||
continue; | ||
} | ||
|
||
display = elem.style.display; | ||
if ( show ) { | ||
if ( display === "none" ) { | ||
// Restore a pre-hide() value if we have one | ||
values[ index ] = dataPriv.get( elem, "display" ) || ""; | ||
} | ||
} else { | ||
if ( display !== "none" ) { | ||
values[ index ] = "none"; | ||
|
||
// Remember the value we're replacing | ||
dataPriv.set( elem, "display", display ); | ||
} | ||
} | ||
} | ||
|
||
// Set the display of the elements in a second loop | ||
// to avoid the constant reflow | ||
for ( index = 0; index < length; index++ ) { | ||
if ( values[ index ] != null ) { | ||
elements[ index ].style.display = values[ index ]; | ||
} | ||
} | ||
|
||
return elements; | ||
} | ||
|
||
return showHide; | ||
|
||
}); |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we pull
.show()
and.hide()
into this file and remove the dependency inside css.js completely? That way it becomes a separate module and can be removed in a custom build if you use classes for showing and hiding.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So, introduce a new showHide module (
.show
,.hide
, and.toggle
) depending on data and depended upon by effects? That sounds reasonable, but out of scope for this ticket.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, it can go in a different ticket and pull request, I'll create an issue. Now that
showHide
is broken out it seems pretty clear we could do that, and in fact the new module only helps with size reductions if it can be excluded. As it is right now, it can't ever be excluded because of the dependency here.