I have a jQuery plugin that returns an instance of a regular javascript class. Inside this class I have a public method setting the style of the selector element with jquery.
Example:
http://jsfiddle.net/v4hcC/1/
As you can see jquery doesnt set the css of the element when it receives the undefined argument (value). But if I remove the second argument (value) jquery sets normally the css into the element.
Example:
http://jsfiddle.net/mb8Je/3/
Obviously, in the second example it will not set the border at all (no second argument). But the first example now works. Why?
UPDATE: I know that if I do this it will work
-
if($.isPlainObject(style)) {
options.elemento.css(style);
} else {
options.elemento.css(style, value);
}
But I want this to work as the following:
-
options.elemento.css(style, value);
UPDATE:
This is not a matter of test the value argument inside the method, but
make the thing work without any modification in its structure. Since the
css() receives 2 arguments and my method passes the identical 2, the
method css() should behave equally in both, but thats not what is
happening. Why?