This project is archived and is in readonly mode.

#1231 ✓invalid
Partikule

setStyle() negative value and IE7

Reported by Partikule | May 19th, 2011 @ 07:47 AM

Some softs developped with mootools calculate the height / margin, etc. of DOM elements and set them through the Element.setStyle() function.

Sometime, the sended value can be negative.
Modern browsers don't care but IE7 fired an error : "Member not found" at line 3566. (test on margin)

The solution could be to replace, in Element.setStyle declaration :

this.style[property] = value;

by

try {
    this.style[property] = value;   
}
catch(e){}

... or to set the nagative margin value to 0...

Comments and changes to this ticket

  • Ger Hobbelt

    Ger Hobbelt May 19th, 2011 @ 08:53 PM

    partial fix for that in commit @092621a2324c4068e25a41a762df0f68f7e85e86 at github. It doesn't check margin styles and is not so nice as it dumbly checks for negative numbers via string check as that was the easiest way to catch, for example, both '-20px' and numeric '-20' inputs with minimal code.

    Question is, though, whether mootools should have such 'garbage in' filters; I did it that way, but I'm still not completely happy about the fix from back then. Given that I look at software as 'should fix where the issue starts' whenever possible, this commit is an example of the contrary of that approach.

  • fakedarren

    fakedarren July 16th, 2011 @ 04:40 PM

    • State changed from “new” to “invalid”

    I'm sorry, I'm probably missing something here.

    http://jsfiddle.net/GwL5N/ works fine in IE7.

    Can you update the example to show this error occurring?

    Cheers
    Darren

  • Partikule

    Partikule July 24th, 2011 @ 10:03 AM

    @fakedarren : Making it working with an unit test isn't the solution.

    Setting a negative value in IE7 can return an error depending on the parent div property.
    Of course I didn't got the time to test it much deeper but IE fired an error on setting negative value on margin.

    I got this issue with a complex mootools application (mochaUI).

  • Arian

    Arian July 25th, 2011 @ 11:32 AM

    • State changed from “invalid” to “open”

    I got this issue with a complex mootools application (mochaUI).

    That shouldn't matter, eventually it will be like something as Darren posted.

    It seems to occur only with width and height.
    Solving this with a try-catch is usually wrong and might hide other valuable errors.

  • Partikule

    Partikule July 25th, 2011 @ 11:33 AM

    Example available here :

    http://partikule.partikule.net/mootools_setstyle_bug/index.html

    This example should be open with IE8 and IE7.

  • ibolmo

    ibolmo January 19th, 2012 @ 09:47 AM

    • State changed from “open” to “invalid”

    Moved to Github Issues: https://github.com/mootools/mootools-core/issues/2233

    Please use Github Issues, since Lighthouse has been deprecated.

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile »

Shared Ticket Bins

Pages