{ib}Unable to set "display" style prop. from JS code

RESOLVED DUPLICATE of bug 171830

Status

()

P4
major
RESOLVED DUPLICATE of bug 171830
17 years ago
16 years ago

People

(Reporter: ptashek, Assigned: attinasi)

Tracking

Trunk
Future
Points:
---

Firefox Tracking Flags

(Not tracked)

Details

Attachments

(3 attachments, 1 obsolete attachment)

(Reporter)

Description

17 years ago
I have code like this in HTML:

<input TYPE="BUTTON" CLASS="EDIT" VALUE="SHOW FILTER DIALOG" 
OnClick="ToggleFilter('dfilter',1);"><form NAME="dfilter" ACTION="$PHP_SELF" 
STYLE="display: none;">
<table BORDER="0">
.
.[some content]
.
<tr><td><input TYPE="BUTTON" CLASS="EDIT" VALUE="HIDE FILTER DIALOG" 
OnClick="ToggleFilter('dfilter',0);"></td></tr>
</table></form>

and the ToggleFilter() function in an external JS file:

function ToggleFilter(filterForm,isOn) {
	if (isOn == 1) {
		document.forms[filterForm].style.display = "inline";
	} else {
		document.forms[filterForm].style.display = "none";
	}
}

The above code should display my form when isOn == 1 and hide it in any other 
case. While the showing works OK, there is a problem with hiding the form back. 
JSEngine in Mozilla doesn't do anything although the "else" part is fired 
(tested with some other code). JS Console reports no errors/warnings/whatever

In MS Internet Explorer 5.x/6 everything works smooth.

Tested mozilla builds: 0.9.6, 0.9.8, 1.0 RC1, 1.0 final, 1.1 alpha (build 
2002070204) and 1.1 alpha (build: 2002070708)
If you use "block" instead of "inline" to show, does it work?

Comment 2

17 years ago
Re: comment 1 - Yes, I tested it with block, and it works.

Comment 3

17 years ago
Also seems to work if you remove the table code.
To layout.  I'll investigate in more detail tomorrow....
Assignee: rogerl → attinasi
Component: JavaScript Engine → Layout
QA Contact: pschwartau → petersen
Summary: Unable to set "display" style prop. from JS code → {ib}Unable to set "display" style prop. from JS code
(Reporter)

Comment 5

17 years ago
Yes, it works if changed from "inline" to "block".
However, it should work with both.

Comment 6

17 years ago
Should it? If you switch FORM to "display: inline" then you're saying an inline
element (FORM) should contain a block element (TABLE). That can't be right.

-> INVALID
Status: UNCONFIRMED → RESOLVED
Last Resolved: 17 years ago
Resolution: --- → INVALID
Reopening.  There's nothing wrong with having a block inside an inline (except
in the HTML4 specification, but those are different blocks and inlines).

We should be handling this case; I have not yet figured out what breaks here...
Status: RESOLVED → UNCONFIRMED
Resolution: INVALID → ---
Created attachment 90598 [details]
Minimal testcase

OK, this is quite confusing....  I've traced the code, and even calling
RecreateDocElementHierarchy (which succeeds and all that) does not make the
second <input> disappear.....

Could this have something to do with the framestate restoration forms do, by
any chance?
Created attachment 90600 [details]
same without form controls.  :(
Attachment #90598 - Attachment is obsolete: true
Status: UNCONFIRMED → NEW
Ever confirmed: true
OS: Windows NT → All
Hardware: PC → All

Comment 10

17 years ago
Created attachment 90603 [details]
This one works..

I don't know if this is relevant, but this is a simple script I use on an
intranet which toggles the display of a span between none and inline. Works
fine in Moz.
Lasse, your testcase has no blocks inside the <span>.  Hence it works.

Updated

17 years ago
QA Contact: petersen → moied

Updated

17 years ago
Priority: -- → P4

Comment 12

17 years ago
*** Bug 163451 has been marked as a duplicate of this bug. ***

Updated

17 years ago
Target Milestone: --- → Future

Comment 13

16 years ago
*** Bug 174704 has been marked as a duplicate of this bug. ***

Comment 14

16 years ago
Created attachment 105349 [details]
Small testcase

I've encountered this bug while developing a product for IBM which generates
HTML output. I've attached a small testcase. The 'click to flip' link works
only once (in IE it works repeatedly). Note that everything works fine if the
table is removed.

Since I need to hide/reveal the entire table, the workaround I've found is
marking the <table> itself as the element to hide/reveal, without an enclosing
<span>. It seems to work with Mozilla 1.1. Has anyone tried this before and
encountered any problems?

I realize this workaround can probably be used in general when you have to play
around with whole blocks (just replace the <span> with a single-cell <table>),
but the bug itself seems painful and must be solved.
tal, you're not seeing this bug.  You're seeing bug 146409 or something it
blocks (as in, my build with the patch for that bug works fine on your testcase
but fails the testcase in comment 9).

In general, testing this bug without a build with that patch or equivalent is
pointless, since the almost all occurrences of these symptoms are fixed by that
patch...
Looks fixed by bug 171830

*** This bug has been marked as a duplicate of 171830 ***
Status: NEW → RESOLVED
Last Resolved: 17 years ago16 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.