The way how jQuery does mixing properties with attributes is a very
clever thing. One simple API for multiple different things is a very
nice thing, but has its constraints.

An example:

jQuery returns the value-property on form-elements, instead of the
value-attribute. This is a really good thing, because
a) a lot of novice developers don´t know about the difference and are
expecting this behavior
b) more advanced developers know the difference, but want in general
to know the value-property of a form element

With other words the developer gets what he/she wants/expects here.

But if jQuery starts to make .attr('height') equal to .height(), the
behavior becomes very unexpected. Everybody knows that the height-
attribute can be simply "overridden" by using css. This is why a
developer would use height to get the height-dimension of an element
and if a developer wants to know what the height-attribute, he would
call attr('height').

If you change your API to this behavior you will
a) break existing code
a) do unexpected things
b) you don´t have a jQuery-method, wich returns the height-/width-
attribute anymore

To be clear:

I think, you did a great job mixing properties and attributes and if
you know start to take this a step further, I am also on your side,
but you have to make wisley decissions (and small steps) here.

If you can solve the discrepancy in event-binding with attr, Robert is
mentioing, it could be a nice feature, but please don´t do this with
height/width!

On 17 Dez., 11:28, Már Örlygsson <mar.orlygs...@gmail.com> wrote:
> > Never ever, would I have guessed that .attr('height') would report a
> > value on elements that don't have an explicit height `attr`ibute.
>
> Somehow I have the feeling that it would be useful for developers to
> be able to access plain old element attributes - in a cross-browser
> way - without any overt aliasing/magic.
>
> --
> Már

--

You received this message because you are subscribed to the Google Groups 
"jQuery Development" group.
To post to this group, send email to jquery-...@googlegroups.com.
To unsubscribe from this group, send email to 
jquery-dev+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/jquery-dev?hl=en.


Reply via email to