in partnership with mediatemple

Ticket #202 (closed defect: invalid)

Opened 1 year ago

Last modified 2 months ago

[Error : Invalid argument] in setStyle in IE (solution inside)

Reported by: SchizoDuckie Owned by:
Type: defect Priority: major
Milestone: Component: Core
Keywords: Error Invalid argument IE Cc:

Description

I've uncovered and patched a tiny bug preventing [Error : Invalid argument] in IE in some occasions:

setStyle: function(property, value){
		switch(property){
			case 'opacity': return this.setOpacity(parseFloat(value));
			case 'float': property = (window.ie) ? 'styleFloat' : 'cssFloat';
		}
		property = property.camelCase();
		switch($type(value)){
			case 'number': if (!['zIndex', 'zoom'].contains(property)) value += 'px'; break;
			case 'array': value = 'rgb(' + value.join(',') + ')';
		}
		this.style.property = value; // change from this.style[property] because of bug in IE.
		return this;
	},


Change History

Changed 1 year ago by SchizoDuckie

Okay i fiddled around with this some more.

the fix above is wrong.
The problem came from setting a NANpx value to marginLeft which was in turn triggered from one of these effects:

	linkEvents: 
	{
		'mouseenter': function(ev) 
		{
			this.fx1 = this.getElement('.links').effects(this.fxOptions).custom({'opacity':[0, 1]} ); 
			this.fx2= this.effects(this.fxOptions).custom({'marginLeft':[0, 25]});			
			
		},
		'mouseleave': function(ev) 
		{
			if(this.fx1) { this.fx1.stop(); this.fx1.custom({'opacity':[this.fx1.now['opacity'], '0']}); }
			if(this.fx2) { 	this.fx2.stop(); this.fx2.custom({'marginLeft':[this.fx2.now['marginLeft'], 0]}); }	
		}
	},

There seems to be some weird rounding effect in some cases.
Still, this should be fixed as it stops the current function running somehow:

suggested patch:

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

Changed 1 year ago by digitarald

  • status changed from new to closed
  • resolution set to wontfix

try catch is slow, please reopen this ticket if this error still occurs.

Changed 1 year ago by SchizoDuckie

How about this then:

if (value != "NaN") this.style[property] = value;

Changed 3 months ago by anonymous

  • priority changed from minor to major
  • resolution deleted
  • status changed from closed to reopened
  • component set to Core

problem is in the Element.fixStyle function, which in several cases returns 'auto' for elements, which's style property was not set via javascript to some numerical value.
when zou set this style property to for example '1px'. the problem is gone. But not resolved of course :)

maybe solution would be to rewrite this method, so it would retur computed style.

Changed 3 months ago by anonymous

and...

in setStyle function:
...
switch($type(value)){

case 'number': if (!['zIndex', 'zoom'].contains(property)) value += 'px'; break;
case 'array': value = 'rgb(' + value.join(',') + ')';

}
if(value=='NaNpx?'){return;}

if((property=='width' property=='height') && value.toInt()<0){value='0px';} // here you can add properties which make problems in IE


this.style[property] = value;

this is non systematic solution, but it can make your app work in IE

Changed 2 months ago by SaX

While creating a ImageCrop? class i also came across this problem in IE, IE stops at

this.style[property] = value; (within the setStyle function)

when i'm trying to set a negative width value.

Changed 2 months ago by kamicane

  • status changed from reopened to closed
  • resolution set to invalid

sorry, this is not a valid ticket.

  • Please be precise about the MooTools version / build you're using.
  • Please include a testcase where applicable.
  • We do not accept bug reports for beta browser versions.
  • Please include the full browser version.
  • Please test with trunk, as the bug might be already fixed.
Note: See TracTickets for help on using tickets.