Closed Bug 36167 Opened 25 years ago Closed 25 years ago

Setting style property to empty string should remove style

Categories

(Core :: DOM: CSS Object Model, defect, P3)

x86
Windows 95
defect

Tracking

()

VERIFIED DUPLICATE of bug 9876

People

(Reporter: dan6992, Assigned: jst)

References

()

Details

If you can try this example in both IE4+ and Mozilla! (I'm using M14) As you can see by the example when you set an elements style using element.style.property = 'value' and then set that same property to an empty string using element.style.property = '' the style remains at the value set by the previous call. In IE4+ however this causes the style to be removed, and normal cascading rules take over turning it back to the style value set in the upper level style sheet. Now I know DOM2 defines a removeProperty function that would fix this problem, but I think most people would epect that setting a value to an empty string via JS would have the same effect as setting it to an empty string in the actual style sheet.
what would happen if the yellow had been inherited from another div or from the default color for body text?
Wanted to note a little more here: when you mouse in it changes from yellow to red, but it seems like when you mouse out it should change back to yellow (since it gets set to ''). Short discussion at http://x28.deja.com/viewthread.xp? thitnum=5&CONTEXT=956115150.703397889&back=netscape.public.mozilla.dom
Status: NEW → RESOLVED
Closed: 25 years ago
Resolution: --- → DUPLICATE
We are going to implement the functionality of removing style but we are also going to follow what the spec says about it (http://www.w3.org/TR/2000/CR-DOM- Level-2-20000307/css.html#CSS-CSSStyleDeclaration) which means that it will be done through removeProperty(). See bug 9876 for more info. We are also going to accept an empty string in SetProperty() as an equivalent to RemoveProperty() because it's syntactically correct. It means that the two declarations below will be identical: this.style.setProperty('color', '', '') this.style.removeProperty('color') IE's behavior is plain wrong: a CSS declaration should not accept an empty string. Besides, the example provided by the reporter only works in WinIE5, not in the new MacIE5 although MacIE5 may also accepts empty strings as in: <STYLE> .blah { color: red; } .blah:hover {color:;} /* This is wrong! */ </STYLE> <A CLASS=blah href="qwe">This is blah</A> Marking duplicate of 9876. *** This bug has been marked as a duplicate of 9876 ***
Verified duplicate.
Status: RESOLVED → VERIFIED
Component: DOM Level 2 → DOM Style
You need to log in before you can comment on or make changes to this bug.