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 )
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)
Change History (11)
comment:1 Changed 17 years ago by
comment:2 Changed 17 years ago by
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
Type: | bug → enhancement |
---|
comment:4 Changed 17 years ago by
Summary: | Make .show() element-aware → [PATCH] Make .show() element-aware |
---|
comment:5 Changed 17 years ago by
need: | → Commit |
---|
comment:6 Changed 17 years ago by
Milestone: | → 1.1.3 |
---|---|
Summary: | [PATCH] Make .show() element-aware → Make .show() element-aware |
Type: | enhancement → bug |
Version: | → 1.1.2 |
comment:7 follow-up: 9 Changed 16 years ago by
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
Description: | modified (diff) |
---|---|
Milestone: | 1.1.3 → 1.1.4 |
Version: | 1.1.2 → 1.1.3 |
Marked #1208 as a duplicate of this bug (some good test cases were provided with it).
comment:9 Changed 16 years ago by
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.
Just creating a similar tag breaks for elements that change display type based on the cascade or a style, for example:
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.