Blogging Task 4: search for and read the information that describes the new features in release 1.3 of jQuery up to the current 1.3.2 version; write a blog post summarising the main new features of jQuery 1.3

Wha is the New Features in release 1.3 of jQuery up to the current 1.3.2 version?

Any Changes?

There is a change that jQuery’s selector engine which re-orders the returned results to be in document order, instead of the order in which the selectors were passed in. This was done in order to be in compliance with the Selectors API specification (which jQuery uses, internally, in browsers that support it).

For example

 // jQuery 1.3.1 (and older)
 $("h1, h2, h3")
 => [ h1, h1, h2, h2, h3, h3 ]
 // jQuery 1.3.2
 $("h1, h2, h3")
 => [ h1, h2, h3, h3, h1, h2 ]

New function and changed features!
jQuery now become possible to call 'event.stopPropagation()' or 'return false' within a .live() callback and have it stop the bubbling of the live event. This means that you can now bind live events inside each other and have the inner handlers prevent the outer handlers from firing.
for example
<ul>
   <li><b>Google</b></li>
   <li><b>Yahoo</b></li>
 </ul>
 <script>
   $("li").live("click", function(){
     $(this).addClass("active");
   });
   $("li b").live("click", function(){
     $(this).addClass("active");
     return false;
   });
 </script>

:visible/:hidden Overhauled

We've changed the logic behind the :visible and :hidden selectors (which were used throughout jQuery to determine the visibility of an element).

This is how the logic has changed:

  • In jQuery 1.3.1 (and older) an element was visible if its CSS "display" was not "none", its CSS "visibility" was not "hidden", and its type (if it was an input) was not "hidden".
  • In jQuery 1.3.2 an element is visible if its browser-reported offsetWidth or offsetHeight is greater than 0.

What does this change mean? It means that if your element's CSS display is "none", or any of its parent/ancestor element's display is "none", or if the element's width is 0 and the element's height is 0 then an element will be reported as hidden.

What is the benefit of making this switch? The result is two-fold:

  • The performance is much, much, better. (See below.)
  • An element is reported as "hidden" if it's inside a "hidden" element (something that wasn't possible before, without the use of a plugin)


Performance graph

.height()/.width() Overhauled

.height(), .width(), .innerheight(), .innerWidth(), .outerHeight(), and .outerWidth() have all been overhauled - dramatically improving their speed in all browsers.


Selector speed up in IE

.appendTo()/etc. Now Return Inserted Elements

This is a (minor) API change - resolving a bug in the jQuery API. The methods appendTo, prependTo, insertBefore, insertAfter, and replaceAll all now return the set of inserted elements, instead of the original set of elements.

To understand this change we need to look at a simple example.

Given the following markup, in jQuery 1.3.1 (and older) the following would occur:

 <div></div>
 <div></div>
 <script>
 $("<p/>")
   .appendTo("div")
   .addClass("test");
 </script>

The result in 1.3.1 (and older):

 <div><p></p></div>
 <div><p></p></div>

This was due to the fact that .appendTo, etc. would only return the elements that were passed in to it, instead of the elements that were actually inserted (and since only a single paragraph was passed in - the first one to be inserted - only the first paragraph had the class added to it).

Thus, if you were to run the same code in jQuery 1.3.2 you would end up with:

 <div><p></p></div>
 <div><p></p></div>

Which is the expected result. The only catch is that appendTo, prependTo, insertBefore, insertAfter, and replaceAll all now push onto the jQuery stack (meaning that they're affected by .end()).

We did a survey of existing uses of the above methods and could find no cases where this change would affect any existing code, so we felt safe going ahead with it (especially considering that it's the expected behavior, to begin with).

reference: http://docs.jquery.com/Release:jQuery_1.3.2

Leave a Reply