Bug Tracker

Opened 17 years ago

Closed 16 years ago

#960 closed bug (fixed)

Make .show() element-aware

Reported by: john Owned by:
Priority: major Milestone: 1.1.4
Component: effects Version: 1.1.3
Keywords: Cc:
Blocked by: Blocking:

Description (last modified by john)

From here: http://www.nabble.com/%24.show%28%29-improvement-tf3228045.html

the jquery function show() is at the moment making objects visible by running elm.style.display = 'block';

This works just fine for all block elements (div, etc.) but causes some problems when running on inline elements like links or other elements like table-cells.

I think it'd be better to do this:

elm.style.display = get_type(elm);

function get_type(elm) {

obj = document.createElement(elm.tagName); $('body').append(obj); type = $.curCSS(obj, 'display'); $(obj).remove(); return type;

}

This works for divs as well as for cells.

Benjamin Wiegand

Attachments (1)

show.diff (688 bytes) - added by brandon 17 years ago.
Patch

Download all attachments as: .zip

Change History (11)

comment:1 Changed 17 years ago by Dave

Just creating a similar tag breaks for elements that change display type based on the cascade or a style, for example:

code {
  display: inline;
}
code.chunk {
  display: block;
}

That particular example could be fixed by using clone but the general case can't.

Doesn't setting el.style.display="" revert to the default display type? I think currentStyle/getComputedStyle return the actual display type when you do that, but I haven't tested it for a while and don't know what Safari would do with it.

comment:2 Changed 17 years ago by BenjaminWieg

Doesn't setting el.style.display="" revert to the default display type?

el.style.display = "" doesn't set display to the standard display but to the display defined in the CSS (which may be also "none")

comment:3 Changed 17 years ago by john

Type: bugenhancement

Changed 17 years ago by brandon

Attachment: show.diff added

Patch

comment:4 Changed 17 years ago by brandon

Summary: Make .show() element-aware[PATCH] Make .show() element-aware

comment:5 Changed 17 years ago by john

need: Commit

comment:6 Changed 17 years ago by john

Milestone: 1.1.3
Summary: [PATCH] Make .show() element-awareMake .show() element-aware
Type: enhancementbug
Version: 1.1.2

comment:7 Changed 16 years ago by genezys

Sorry to spam but I do really think that this patch is overkill.

Just calling removeAttribute("display") on the element will just revert the display back to its default value (set in CSS by the designer). I really think that there is no issue with that and that this behaviour is better than the one in the patch.

If a <div> element is defined "inline" in the CSS, a hide()/show() should keep this setting and not revert the div to "block" just because this is the default display for a div.

comment:8 Changed 16 years ago by john

Description: modified (diff)
Milestone: 1.1.31.1.4
Version: 1.1.21.1.3

Marked #1208 as a duplicate of this bug (some good test cases were provided with it).

comment:9 in reply to:  7 Changed 16 years ago by brandon

Replying to genezys:

First we remove the display style property and then and only then if the element is still hidden do we try and figure out its default display style vs just using block.

comment:10 Changed 16 years ago by brandon

Resolution: fixed
Status: newclosed

Fixed in Rev [4074]

Note: See TracTickets for help on using tickets.