jQuery 1.8 Beta 2 Released

Posted on by

It’s been a crazy few weeks around jQuery Central, what with the release of Beta 1 and the jQuery Conference in San Francisco following that. Fear not! Between all the travel, conferences, meetings, and blog posts about the future of jQuery, we’ve actually managed to write some more code. As proof, here is jQuery 1.8 Beta 2:

http://code.jquery.com/jquery-1.8b2.js

This is the critical section in the program where we call on you, the jQuery community, to help us bring this one home. Use Beta 2 with old browsers, new browsers, red browsers and blue browsers. (That’s IE6, Chrome Canary, Opera, and Internet Explorer, respectively.) Test this file with all your code, please test it well in every mode. Did something break in Beta 2? Please tell us now before we’re through!

With assistance from those of you who tested Beta 1, we found a few bugs and squashed them. We can’t emphasize enough how important it is for us to get feedback from you as you test with these beta versions. We don’t like releasing final versions that cause problems when you drop them into your web pages, and the way to prevent that is to test with the beta and let us know about problems in advance.

NOTE: This release required coordination with jQuery UI to fix a few problems. For that reason, pages using jQuery UI will need to include the latest UI master version to test against jQuery 1.8b2. You can get it here: http://code.jquery.com/ui/jquery-ui-git.js. There will be a maintenance release of jQuery UI 1.8 that includes jQuery core 1.8 support, but users are encouraged to update to jQuery UI 1.9 when it is released.

If you find a problem, please try to reduce it to a simple test case. jsFiddle is our preferred way to get test cases, since it allows us to tweak the test case, diagnose the problem, and explore solutions. (Select jQuery (edge) for the framework, which is the latest code.) With test case in hand, head over to the bug tracker and let us know what happened. Thanks!

In addition to bug fixes reported in Beta 1, this new beta also has a significant rewrite of the Sizzle engine for even better performance. It fixes a big pile of bugs related to IE 6, 7, and 8 and makes those browsers more consistent to use. Perfection with oldIE will always be an elusive thing, but we’re still trying to make your development life as easy as possible no matter the browser.

If you build your own custom versions as described in the README file on Github, you now have the option of leaving out some of the deprecated functionality that will be removed in future versions. We’ll be adding to this file as we isolate additional deprecated functionality.

Below is a complete list of the changes since jQuery 1.7.2.

jQuery 1.8b2 Change Log

The current change log of the 1.8b2 release.

Ajax

  • #4624: Charset in default ajaxSettings.contentType
  • #10978: jQuery.param() should allow non-native constructed objects as property values
  • #11264: evalScript() uses defaults set by ajaxSetup()
  • #11426: jQuery.ajax() always fails when requesting JPG images in IE

Attributes

  • #5571: Allow chaining when passing undefined to any setter in jQuery
  • #10828: attr("coords") returns undefined in IE7
  • #10870: Incorrect behaviour of $.removeAttr("selected")
  • #11316: Consider looking through valHooks by element type first, then by nodeName instead of the other way around

Build

  • #10692: Configure the jshint options to more accurately match the style guide
  • #10693: generalize the "test something in an iframe" code in unit tests
  • #10901: have unit tests fail if the tester is running from file:// or doesn't have PHP
  • #10902: ability to test a built version of jQuery in unit tests
  • #10931: Unit tests shouldn't require internet access

Core

  • #10466: jQuery.param() mistakes wrapped primitives for deep objects

Css

  • #10639: outerWidth(true) and css('margin') returning % instead of px in Webkit
  • #10754: have jQuery.swap return the return of the callback instead of just executing it
  • #10782: Incorrect calculating width
  • #10796: Bug in IE7 with $('#el').css.('background-position')
  • #10858: css.js regular expressions are incomplete
  • #11119: The curCSS function only need 2 arguments

Data

  • #11309: hexadecimal-formatted data-* attributes parsed incorrectly

Deferred

  • #11306: calling .disable() or .lock() on a $.Callbacks object breaks its fired() status

Effects

  • #8498: Animate Hooks
  • #10006: method show is not working as expected in all browsers when called for document fragment
  • #10848: Animation toggling loses state tracking in certain atomic edge cases
  • #11415: Silently ignore negative CSS values where they are illegal
  • #11469: Negative margin in animations (.animate)

Event

  • #8165: .live('click', handler) fires on disabled buttons with child elements in Chrome
  • #10819: Eliminate "this.on.call(this, "
  • #10878: $("select").live("change", function(){ …broken in IE8 in jQuery 1.7
  • #10961: Error in XRegExp using jQuery 1.7.1 in IE6-9
  • #10970: The .on() selector parameter doesn't work with :not(:first) selector
  • #10984: Cannot off() custom events ($.event.special)
  • #11021: Hover hack mangles a namespace named "hover"
  • #11076: .clone(true) loses delegation filters
  • #11130: jQuery.fn.on: binding map with null selector ignores data
  • #11145: $(document).on() not working with name="disabled"

Manipulation

  • #9427: Passing undefined to .text() does not trigger setter
  • #10753: inline the evalScript function in manipulation.js as it's only used once
  • #10864: text() method on a document fragment always returns the empty string
  • #11055: Update HTML5 Shim elements list to support latest html5shiv
  • #11217: Append problem with webkit
  • #11291: Cloning XMLDoc's with HTML5 nodeName's breaks on IE
  • #11323: script tags with type="text/ecmascript" leak into the DOM
  • #11356: safeFragment memory leak

Misc

  • #10952: .fired() doesn't work on Callbacks object when it is flagged with "once"
  • #11257: Wrong path to source files in test suite if PHP missing

Queue

  • #10967: .promise() does not attach methods onto target

Support

  • #7986: Bug in $.support.boxModel if page has DIV-element CSS
  • #11048: Support Tests affect layout for positioned elements in IE6-9
  • #11337: Bug in $.support.reliableMarginRight

Traversing

  • #11370: $('<div>').siblings() throws exception

The New Sizzle

Posted on by

In order to make your 4th of July more sizzlin’ (you’re welcome), the jQuery team is happy to announce that Sizzle, jQuery’s CSS selector engine, is better, faster, and more reliable than ever! Sizzle has received a substantial rewrite to be included with the release of jQuery 1.8.

First, credit should be given to Diego Perini for pointing me in the right direction as well as Samuel Lebeau for creating a project 3 years ago called Bouncer, a “fast bottom-up element matcher for Javascript”.

jQuery, along with Sizzle, was released in 2006, about 3 years after Simon Willison came out with getElementsBySelector, which pretty much set the stage for every selector engine we have today. As time went on, Sizzle was rewritten a few times for the sake of performance and more and more bugs were covered as the number of people using it increased.

During this time, other quite impressive selector engines were introduced, including but not limited to NWMatcher (by Diego), dojo.query, Slick, base2, qwery, and YUI. Though they all have their own strengths, NWMatcher and Dojo particularly stood out as exemplary engines. While neither is the fastest at every selection, they are both consistently fast for almost every selector. My goal was to achieve this same level of performance for Sizzle, retain all of the edge-case bug fixes that John and the bugs team have collected over the years, and cover even more bugs that were in the queue or were covered by other engines. I can now safely say this goal has been reached.

While I won’t say Sizzle is completely bug free or it is always the fastest in every situation, the reliability and performance gains are very competitive. http://jsfiddle.net/timmywil/s7rN4/ is a primitive test used to quickly observe the differences between some selector engines for several selectors (should be run in a browser with a console open).

What changed

Below is a reduced list of the main code differences between Sizzle in jQuery 1.7.2 and jQuery 1.8.

One compiled selector function

The selector parser compiles a selector into one function containing functions for each part of the selector. This means that for any given selector (excluding positional (POS) selectors such as :first or :eq(3)), the possible set of elements need only be checked once. This is predominantly where the major speed boost and heightened stability comes from.

Additionally, Sizzle maintains a cache of the most recently compiled functions. The cache has a maximum size (which can be adjusted but has a default) so you don’t get out-of-memory errors when using a lot of different selectors.

Note: this does not have an effect on simple selectors (ID-only, TAG-only, CLASS-only) because Sizzle has had shortcuts for these that defer to getElementByID, getElementsByTagName, and getElementsByClassName whenever possible. That wasn’t changed (except for the addition of a shortcut for element-rooted ID selectors), and those are still the fastest selectors. Any other selector will go through querySelectorAll if available or run through the compiler.

querySelectorAll and matchesSelector

With this latest rewrite, the code paths to querySelectorAll and matchesSelector are even better than before and yield excellent performance.

Some people ask why we need Sizzle at all, since modern browsers have querySelectorAll and matchesSelector and accept a wide range of CSS3 selectors. The problem is that every browser (not just IE) has a few bugs in these methods. Selector engines must know beforehand what these bugs are and bypass these methods before they return incorrect results (though not all of them do). Sizzle now has this covered.

In addition, querySelectorAll and matchesSelector do not know how to process jQuery selector extensions such as [attr!=value]. Any time you use a selector extension, Sizzle needs to handle the selection natively.

Improved selector validation

Validating selectors is a tricky business. To be too strict can be annoying, but to be too flexible can produce unexpected results. In the past, Sizzle has been both of these at different times for several use cases. The most recent changes are geared towards adhering to the W3C selectors specification as much as possible, but also allowing some things that the spec does not (such as having complex selectors within a :not() pseudo).

Specifically, we are matching all whitespace characters where necessary, including line feed, tab, carriage return, and form feed(http://www.w3.org/TR/selectors/#whitespace), validating identifiers and operators in attributes selectors (http://www.w3.org/TR/selectors/#attribute-selectors), and providing a character encoding that matches the spec (http://www.w3.org/TR/css3-syntax/#characters).

Combinators (space, ~, >, +)

Combinators can get very complicated, but the new strategy handles these with great poise. In the release of jQuery 1.8 beta (and at the jQuery conference this year), I claimed that Sizzle had improved support for combinators. While the accuracy was improved, I spoke too soon and, fortunately, this was pointed out by someone I only know as Yaffle on github. Apparently, for very large and deep documents, the original revisions were checking so many elements that it was causing a stack overflow for selectors that had several combinators. For each combinator, the number of elements checked went up exponentially in order to maintain possible matches. This was bad. Sizzle now takes care of that issue and gets very satisfying results.

Extensibility

Although most of the old API for Sizzle was not changed in this rewrite (except for the removal of the now unnecessary Sizzle.filter from the private API), there are a couple changes that make Sizzle even more extensible. The most common way to extend Sizzle is to add custom pseudo selectors. Now with the parser compiling a function of functions, you can receive more information when creating your custom selector. For example, within Sizzle, the implementation for the :not pseudo selector is very similar to

// Using the createPseudo function tells the compiler
//   to pass the pseudo argument, context, and whether the current context is xml
//   to the function passed to createPseudo and trusts
//   that a function to be used for filtering will be returned.
// Note: the use of createPseudo is only necessary for creating custom
//   pseudo selectors with arguments.
Sizzle.selectors.pseudos.not =
    Sizzle.selectors.createPseudo(function( selector, context, isXml ) {
        var matcher = Sizzle.compile( selector, context, isXml );
	return function( elem ) {
		return !matcher( elem );
	};
    });

This is the only breaking change in the public API given the new parser, but I think creating custom pseudos with arguments is now much cleaner. For more information, please refer to the Sizzle docs.

Perhaps some of you are thinking that it could be nice to pre-compile your own selectors. Well, you can. Sizzle.compile is exposed so you can cache your selectors before they get used. While compiling is still very fast without caching, you can make sure that step is skipped before the selection is ever run. Call compile with your selector and context

Sizzle.compile(“my>long>complicated:selector(poof)”, document);

and it’s added to the cache. You can even increase/decrease the size of the cache by setting Sizzle.selectors.cacheLength.

Note: The majority of users do not need to use the compiler as Sizzle will maintain a cache of recently compiled selectors. Overriding Sizzle.compile will have no effect on Sizzle as it maintains an internal reference to this method.

Get the code!

The code is now available in the git versions of jQuery and Sizzle. Expect jQuery 1.8 to be released sometime this month. Issues specifically for Sizzle can be filed on GitHub and, as always, any issues related to jQuery as a whole can be filed on our bug tracker. Try it out for yourself and let us know if you run into any problems. Enjoy and Happy Independence Day!

jQuery 1.9 and 2.0 — TL;DR Edition

Posted on by

It seems that many people had questions and misconceptions about the last post, so let’s try a short Q&A format to answer some of the comments left there.

Why is the jQuery core team dropping support for oldIE (IE 6/7/8)? We’re not! jQuery 1.9 will support oldIE when it’s released next year. The jQuery team will continue to support and maintain version 1.9 even after jQuery 2.0 is released.

Why are you making me use conditional comments to include jQuery? We’re not! You can use jQuery 1.9 for all the browsers we support, from IE6 all the way up to the latest versions of Chrome, Safari, Opera, or Internet Explorer.

What happens when jQuery 2.1 is released and adds APIs, will jQuery 1.9 support them? Can we borrow your crystal ball? jQuery 2.1 isn’t likely to arrive until 2014, so it’s hard to say what jQuery 2.1 will look like as we sit here in the middle of 2012. Our general goal is to keep the 1.x and 2.x lines in sync and add functionality via plugins; see the keynote from last week’s conference.

How long will you support jQuery 1.9? As long as oldIE is a significant factor on the web. It’s even possible that there will be further releases in the 1.x line, but we haven’t yet received the crystal ball requested in the previous question. When Microsoft drops Windows XP support in April 2014, however, it will put a hurt on the oldIE installed base.

I still have a lot of IE8 users, can’t you just drop IE6 and IE7? The oldIE browsers share many of the same flaws, so it doesn’t help to do anything less than remove all three in jQuery 2.0. If you need oldIE support of any kind, a supported jQuery 1.9 will be right there for you.

My website is in China and 22 percent of our users are still using IE6! Seems like some sort of human rights violation. Oh, and that wasn’t a question.

jQuery Core: Version 1.9 and Beyond

Posted on by

Please check out the followup post before jumping to the wrong conclusion.

As the last blog post discussed, jQuery version 1.8 is undergoing a spring cleaning to remove insecure, inefficient, ineffective, and inadvisable features. We’ve also begun the work to allow you to build custom versions that exclude parts of the library for even greater savings. Those efforts will make it possible for you to enjoy the jQuery API you need without carrying around the parts you don’t want.

Now that we’ve cleaned house, it’s time to take a look forward. There’s just one thing interfering with our vision of the future, and that’s the ghost of browsers past. Internet Explorer 6, 7, and 8–collectively, oldIE–have been a thorn in the side of web developers for a decade. Collectively, these browsers of a bygone era still represent up to one-third of users visiting some sites. That is a lot of users–people who still want the information, services and products that web sites provide. For many web sites that use jQuery, it’s not practical or profitable to ignore that audience.

jQuery was conceived specifically to address the differences in browsers, so we’re not going to abandon the essence of our philosophy and simply disregard the millions of active Internet users who (for whatever reasons) still use oldIE. Yet we also want to move ahead and take advantage of modern browsers, especially the growing mobile market.

The Road Ahead

jQuery 1.8 should arrive within a month. Here is our thinking about the next two versions of jQuery to follow it, and when they’ll arrive:

  • jQuery 1.9 (early 2013): We’ll remove many of the interfaces already deprecated in version 1.8; some of them will be available as plugins or alternative APIs supported by the jQuery project. IE 6/7/8 will be supported as today.
  • jQuery 1.9.x (ongoing in 2013 and beyond): This version will continue to get fixes for any regressions, new browser bugs, etc.
  • jQuery 2.0 (early 2013, not long after 1.9): This version will support the same APIs as jQuery 1.9 does, but removes support for IE 6/7/8 oddities such as borked event model, IE7 “attroperties”, HTML5 shims, etc.

Our goal is for 1.9 and 2.0 to be interchangeable as far as the API set they support. When 2.0 comes out, your decision on which version to choose should be as simple as this: If you need IE 6/7/8 support, choose 1.9; otherwise you can use either 1.9 or 2.0.

Questions and Answers

If jQuery 1.9 and 2.0 are basically the same API, what makes 2.0 compelling? Smaller size, better performance, and the lack of problems introduced by the need for oldIE support. We expect that we can improve error handling in the $.Deferred implementation in 2.0, for example, whereas we can’t do that as long as oldIE is supported.

My site still has many IE7/8 visitors but I want to use jQuery 2.0. Can I do that? If your web site needs oldIE support, and we expect most sites will need it for at least another year or two, you can use IE conditional comments to include version 1.9 only when visitors are using oldIE:

<!--[if lt IE 9]>
    <script src="jquery-1.9.0.js"></script>
<![endif]-->
<!--[if gte IE 9]><!-->
    <script src="jquery-2.0.0.js"></script>
<!--<![endif]-->

Why not make an “oldIE plugin” for jQuery 2.0? Special dispensations for oldIE are sprinkled throughout jQuery. Refactoring the code to provide enough hooks so that oldIE support could be added as a plugin would complicate the code for the modern browser case. Plus, developers supporting oldIE and using a public CDN would then need to include two files (jQuery 2.0 and the oldIE plugin) instead of one.

Once jQuery 2.0 is released, what happens to 1.9? In a departure from the past, we’ll continue to fix bugs in 1.9 (as minor releases). Having just gone through a spring cleaning for 1.8 and 1.9, we don’t anticipate adding a lot of new APIs in the future. Instead, we prefer to add new functionality through plugins compatible with both versions where it makes sense. So don’t feel like you’re being left behind when using version 1.9.

Is jQuery 2.0 basically for mobile devices? No. Although jQuery 2.0 will be a great fit for HTML mobile apps, including ones written with jQuery Mobile, it is not a Webkit-only library that targets just iOS and Android. In addition to mobile browsers, 2.0 will support (and be tested!) with modern desktop versions of Internet Explorer, Opera, Firefox, Safari, and Chrome.

How much smaller/faster will jQuery 2.0 be? We won’t know until we’re done, or at least close to being done. You can bet that we’ll tell you more as the release date for 2.0 draws near. Better yet, you can try the beta when it is released and see for yourself!

jQuery 1.8 Beta 1: See What’s Coming (and Going!)

Posted on by

Hello fellow jQuery users! It’s been a while since you’ve heard from us, but we haven’t been asleep. The jQuery Core Team has been heads-down working on jQuery 1.8, and our first beta release is now available! You can get the code from the jQuery CDN:

Give it a try on your current jQuery code and let us know how it works for you. If you experience issues, please file a bug, include a test case, and be sure to mention that you’re testing against jQuery 1.8 Beta 1.

There will be even more exciting jQuery news at the jQuery Conference in San Francisco later this month, with blog posts to follow.

jQuery is now powering about one-half of all the major web sites on the Internet; that’s a great success, but we’re not standing still. Web browsers and the devices they run on have undergone an incredible metamorphosis in the past six years. The process of web development is evolving to accommodate the changes that are happening. In response, jQuery continues to evolve as well.

Part of that evolution is not just knowing what to add, but what to take away. jQuery’s plugin architecture makes it easy for developers to extend the functionality that jQuery Core offers when it makes sense for their own needs. For that reason, the bar has been set pretty high for additions to Core. We don’t want to create size, complexity, or performance penalties for people who don’t need specific features.

Similarly, we have enough experience with the way that people use jQuery to know some features that originally seemed like a good idea turned out to be a not-so-good idea. Rather than carry these around forever, we want to remove them eventually. In fact, we want to make it easier to create a version of jQuery that excludes things you don’t need or want, especially for mobile environments where space can be precious.

With that in mind, here are some changes we are planning for jQuery 1.8 that will make it a better foundation for all HTML-based web pages and applications, regardless of their platform:

Modularity

As of jQuery 1.8, you can build a custom version of jQuery that excludes one or more modules if you do not need their functionality. This capability is made easy by our new build system based on Ben Alman’s awesome grunt tool. To build your own custom version, set up a copy of the jQuery core repo from Github and use the grunt command line options to exclude modules. For more information, see the README file.

The modules you can currently exclude are ajax, css, dimensions, effects, and offset. For example, if your application exclusively uses stylesheets and CSS animations via classes to control the visibility and size of items on the page, you could build a version without the css, dimensions, effects, and offset modules. If you didn’t need any of the optional modules, your custom build of jQuery would be about 21KB minified and gzipped.

Don’t worry though, building your own jQuery is completely optional. jQuery has always been, and will continue to be, distributed as a single file in both compressed and uncompressed form and available on CDNs. We still expect that to be the way most jQuery developers go, because it’s simple and painless. For example, when you include a jQuery plugin that you didn’t write, using the full jQuery ensures you won’t be bitten by some dependency lurking inside the plugin.

Vendor-Prefixed CSS Properties

The W3C had its heart in the right place when it came up with the idea to use vendor prefixes for CSS features that were not yet standardized, but it hasn’t resulted in a fairy-tale ending. Web developers are faced with the nightmare of including all the vendor-prefixed property names in stylesheets. jQuery 1.8 eases the pain a bit. We automatically take the non-prefixed property name and generate the prefix that is appropriate for the current browser, so you don’t have to. For example, on Chrome the jQuery call $("#myscroll").css("marquee-direction", "backwards") will set the CSS to -webkit-marquee-direction: backwards.

Animation (Effects)

Our code for animation had become a tangled mess over the past few years, and with 1.8 we hope we’ve brought the beast under control. It’s more than just a cleanup, though; there are several extension points that make it easier to add or modify animations. At the moment there is only preliminary documentation for the new features, but in this first beta our primary focus will be on ensuring that any existing animation code works properly.

Browsers are doing a much better job providing efficient animations today, particularly with CSS transitions. Yet there are still plenty of users who don’t have a browser capable of doing CSS-based animations. With jQuery 1.8 you get the best of both worlds. If you need to support older browsers without built-in animations, the new $.Animation provides a solid foundation and fixes many bugs from previous versions. If you need to target only modern browsers and their natively supported animations, you can do that and exclude the animation module entirely.

Sizzle CSS Selector Engine

jQuery’s selector engine has undergone a major rewrite in 1.8. The most notable benefit of this rewrite is a widespread performance improvement of selector matching as well as improved shortcuts for the most common selectors.

Additionally, Sizzle handles many more edge cases and bugs, including improved support for multiple combinators (~ > +) and better detection of browser bugs in querySelectorAll. See the bugs list below in the selector module for a complete list.

XSS Protection

By design, the $() method can create HTML elements, and will run scripts if it is passed a <script> tag with inline script or a src attribute. Developers have sometimes forgotten this, passing strings to jQuery that come from untrusted sources such as the URL or user input. In these cases, it is possible for someone to inject a script into the page that can steal cookies or compromise the page in some way.

These cross-site-scripting (XSS) attacks are common on many sites whether they use jQuery or not, but we want to ensure jQuery does not contribute to the problem. In jQuery 1.9 (the NEXT version following 1.8), we’re tightening down the “looks like HTML” rule for the $() method. A string will only be considered HTML if the first character is a less-than sign, otherwise it will be assumed to be a CSS selector.

As further protection against the inadvertent injection of scripts, jQuery 1.8 introduces a new method: $.parseHTML. It lets you specify strings as HTML and know that they will be parsed as HTML, something that $() cannot do since it also interprets strings as selectors. It also provides a way to parse HTML into a DOM fragment and control the execution of any scripts the HTML it may contain. This is particularly important in JavaScript environments controlled by Content Security Policy (CSP), since injected scripts may cause security warnings or exceptions.

For anything more than the simple case of creating single elements (e.g., $("<p/>")), and particularly for cases where strings are built from external data, we strongly recommend using $.parseHTML. As of jQuery 1.9, some HTML strings will no longer be recognized by $() as a result of these stricter rules.

Spring Cleaning

In jQuery 1.8 we’ll also be deprecating and removing “trip hazards”: APIs and features that are inefficient, ineffective or inadvisable. We realize that there will be existing jQuery code that still requires these features. To provide a low-hassle future upgrade path, we’ll be providing many of the deprecated items in a compatibility plugin after they are removed. You can follow the compatibility plugin as it is developed on its GitHub repo.

Tickets below that begin with “Deprecate” or “Remove” tell the whole story of what is changed, but here are a few changes of particular note:

$.browser: Ever since jQuery 1.4, we’ve been evangelizing that browser detection via the user agent string is a bad idea. Yet we’ve been an enabler of bad practice by continuing to offer $.browser. As of jQuery 1.9 we’ll remove it entirely and you’ll need to use the 1.9 compat plugin. If your code isn’t weaned off browser detection yet, check out Modernizr for a very thorough set of feature detections you can use instead. And of course, you’re welcome to read the tea leaves in the navigator.userAgent string directly, there’s nothing stopping you but your conscience.

$.sub: This method was introduced in jQuery 1.5, but hasn’t proved to be useful or robust enough to justify it staying in core. It will move to a compatibility plugin in jQuery 1.9.

Global ajax events: Events such as ajaxStart fired by $.ajax can currently be attached to any element–even to elements that are not in a document at all! This creates an inefficient special case, so we are deprecating that behavior in 1.8. Ajax events should be attached only on document as of 1.9.

And Much Much More…

There are many other changes in 1.8, perhaps the easiest way to see what we’ve been up to is to look at the list of issues that are being fixed, which includes both features and bug fixes. Here is a snapshot of 1.8 as it stands today, but it’s not set in stone. We welcome your feedback about specific issues or the direction of jQuery in general!

jQuery 1.8 Beta 1 Change Log

The current change log of the 1.8 Beta 1 release.

Ajax

  • #8205: JSONP random result is causing memory leak in IE8
  • #8653: jQuery.param outputs "null" and "undefined" in the query string
  • #10285: evalScript rcleanScript replacement fails in IE8
  • #10524: jQuery.fn.load does not merge data parameter with jQuery.ajaxSetup
  • #10944: $.ajax does not always return an object implementing the Promise interface
  • #11013: Deprecate/remove async option from $.ajax
  • #11402: evalScript function fails with error error 80020101 in IE
  • #11743: jQuery silently ignores errors during script tag ajax request in $.appendTo()
  • #11778: Cached XHR requests should still resolve asynchronously

Attributes

  • #11153: jQuery 1.7 Strips Carriage Returns in IE 8
  • #11212: Sizzle.getText converts unbreakable space into whitespace on IE

Build

  • #11767: Support custom build without effects
  • #11789: Update README to describe grunt build system
  • #11856: modularize dimensions
  • #11857: modularize css
  • #11865: modularize offset

Core

  • #10657: Deprecate/remove jQuery#size() in favor of jQuery#length
  • #11290: selector interpreted as HTML
  • #11470: Adding a builtin readyP promise

Css

  • #10373: `document.defaultView` => `window`
  • #10413: width, innerWidth, innerHeight, outerWidth, outerHeight are inaccurate for a "box-sizing: border-box" child of hidden parent
  • #10679: CSS3 vendor prefix support
  • #11004: getWH incorrectly removes padding and border width when box-sizing is border-box
  • #11787: Remove jQuery.curCSS

Data

  • #10589: Remove $.fn.data("events")

Deferred

  • #11010: Make Deferred.then == Deferred.pipe like Promise/A
  • #11011: Allow traditional options object for $.Callbacks flags
  • #11736: Remove Deferred .isResolved() and .isRejected()
  • #11749: Preserve context objects when multiple Deferred object are passed to $.when()

Dimensions

  • #6724: wrong $(window).height() in mobile safari (iphone)
  • #10877: Make outerWidth/Height a setter
  • #11293: Reading width or outerWidth of empty TDs alters columns width values
  • #11604: Switch $(elem).width(-val) from no-op to $(elem).width(0)
  • #11724: $(document).height() changed in Firefox 12

Effects

  • #7109: animate width starts with invalid width on webkit
  • #7157: Animation callback shows element is still ":animated"
  • #8387: flickering problem with jQuery 1.5 hide/show issue with inline and inline-block elements on webkit browsers
  • #8627: .animate() fails on letterSpacing in IE (regression in 1.5.1)
  • #8892: Callback is raised before objects are shown with fadeIn() and jQuery.fx.off = true
  • #9505: animate() issue when mixing percentages and pixels in WebKit
  • #11635: Explicit overflow:auto is overridden by inline overflow:hidden during animation
  • #11755: animate and it aliases should not use :hidden selector
  • #11854: percentage animations jump to end

Event

  • #8545: Leak with events in IE
  • #10067: Firing $.ready on document.readyState === 'interactive' too
  • #11101: Deprecate "exclusive" events option from trigger method
  • #11328: Ctrl key doesn't set event.metaKey to true on Windows
  • #11500: Bug : "change" event handler not executed when triggered manually on IE7 & IE8
  • #11621: Triggering a event on document doesn't bubble to window
  • #11718: Deprecate .data() events
  • #11719: Deprecate .bind("ready") event
  • #11731: Deprecate "hover" pseudo-event
  • #11733: Deprecate .load(), .unload(), and .error() methods
  • #11786: Deprecate .toggle( handler, handler, … ) signature

Manipulation

  • #8894: appendTo() and alike methods called after clone() returns incorrect jQuery set in IE
  • #10324: Clone does not copy innerHTML of object element in IE9
  • #11231: Append, Prepend, After, Before should accept an array as first argument
  • #11338: Inconsistent behavior with .replaceWith() and disconnected nodes.
  • #11566: node.append et al. does not work when node is a DocumentFragment
  • #11617: Define a $.parseHTML method for creating HTML fragments

Offset

  • #10996: Simplify offset()
  • #11823: Remove webkitConvertPointFromNodeToPage

Selector

  • #3778: selector matching issues
  • #5568: Selectors behave differently with comments tags on FF/IE
  • #8473: In IE9rc *[tabIndex] select all elements without tabindex also
  • #9400: Deprecate :text, :radio, :checkbox, etc. selector extensions
  • #10003: Regression/BC break from #6963
  • #10074: Chaining two [] selector with :first not working
  • #10570: :text selector throws an error in IE7 when there is a cross domain iframe on the page
  • #10697: Sizzle revamp
  • #10809: incorrect test using ".activeElement" in the :focus pseudo-class resolver
  • #11109: Sizzle: Expr.relative truncates prematurely
  • #11814: Sizzle's element-rooted QSA strategy (i.e. attaching a temporary id) does not account for comma and other other selector divisions
  • #11826: Explore a parsed caching system for matchesSelector within Sizzle

Support

  • #9385: Deprecate jQuery.browser
  • #11439: jQuery.support.parentNode used, but not defined any more.
  • #11721: deprecate and remove internal uses of jQuery.support.boxModel
  • #11766: Move jQuery.support to "unstable" status

Traversing

  • #9800: New method: .addBack (supersedes .andSelf)
  • #11543: .has doesn't work on detached elements
  • #11706: `.has()` fails on document fragments
  • #11738: Remove .closest(Array) returning Array

Unfiled

  • #11325: Improve domManip/buildFragment/clean
  • #11435: Obsolete test code to remove toJSON from .data's return value
  • #11777: Add jQuery Core support for EditorConfig file

Just Added: Training at SF jQuery Conference!

Posted on by

In response to the flood of requests and emails, and our original promise to work on this, we’ve got an announcement: we’ve added a single day Beginner/Intermediate training right before the San Francisco jQuery Conference :)

Tickets are on sale now (left side, below the fold). The training will be provided by our friends at Bocoup, and hosted by the ever-generous folks at Microsoft. Here’s a snippet of what Trainers Ben Alman and Rebecca Murphey will be covering:

At Bocoup’s intermediate one-day jQuery training, you’ll work with jQuery veterans to build a foundation that will make you a stronger developer and get you prepared for all the great talks that you’ll see over the next two days. You’ll even learn the basics of creating your own jQuery plugin. Topics that will be covered include:

  • The jQuery() function
  • Selecting & Traversing
  • Manipulating the DOM
  • Making stuff happen with Events
  • AJAX
  • Enhancing with Effects
  • Extending jQuery with Plugins
  • jQuery UI
  • jQuery Mobile

To note: the training and conference are both in San Francisco, but take place in different locations. The training is in the heart of San Fran on Market Street, and the conference is about five to ten minutes from there, on the UCSF Mission Bay campus. Please also note that the conference and training require separate admission tickets, so make sure you’ve purchased both if you’d like to attend both.

We’re still working on the possibility of adding an Advanced training, but thus far have had mostly requests for beginner materials. So here that is :)

Hope you’ve all bought your tickets to the conference; can’t wait to see you there!

Getting Touchy About Patents

Posted on by

Touch events have become a hot topic for web developers as more and more companies move into the mobile space. Most of us know that touch events support single and multi-touch tracking. Some of us know the trickiness of working with touch and mouse at the same time. Fewer know that there are multiple touch event models, and even fewer have tried to support multiple models at the same time. I’d like to talk about where we are today, how we got here, and the potential problems we may face in the future.

A Brief History

Back in 2007, Apple introduced the iPhone, and with it came touch events. Neil Roberts sums up the Apple implementation well in a SitePen article: “Though at first the APIs seem a little sketchy, once you’ve learned them you should be able to do amazing things in your application.” Sure enough, we’ve seen plenty of amazing things, without too much complaint of the “sketchy” API. This model was later implemented by Android, Nokia, RIM, Opera, and others. Apple’s implementation is still only available in their private fork of WebKit; it wasn’t until the end of 2009 that touch events first appeared in the main WebKit repo, coming from the Android implementation.

Also in 2009, the W3C started discussing a unified pointer model for DOM Level 3 Events. The idea was that touch (including multi-touch), pen/stylus, and mouse events would be coalesced into a single model, making it easy to support all pointer types at once. However, this was abandoned because the goal at the time was to keep the spec as small as possible in order to become a recommendation faster.

Another two years later (March 2011), Mozilla released Firefox 4, featuring their own flavor of touch events. The Mozilla model is much closer to the mouse event model and the abandoned W3C model in that the event objects are flat; properties such as event.pageX exist and there is no touch list. If you want to track multiple touches, you can do so via the event’s streamId. Mozilla later deprecated this implementation in favor of an emerging W3C spec based on Apple’s model.

In January 2011, the W3C started drafting a Touch Events spec based on the WebKit implementation. A few months later, it became a Working Draft, and in December it became a Candidate Recommendation. The next month, a Patent Advisory Group (PAG) was formed in order to investigate patents disclosed by Apple. Apple’s absence from the Touch Events Working Group (WG) and their patent disclosure has caused the W3C to stop work on the spec and they do not plan to continue until the PAG has concluded and/or makes a recommendation to the WG. As of this writing, the PAG has not made a decision about the impact of the patents, but the group’s goal is to reach a speedy conclusion.

Meanwhile, Microsoft took a different approach to touch and has implemented their own pointer events in IE10 with the MSPointerEvent object. The MSPointerEvent object is similar to the original Mozilla implementation, in that the event objects are flat and contain a pointerId property. However, there are some important differences between MSPointer and all of the other models, which are touch-specific.

Note: The above is just a brief history of touch events on the Web; if you’re interested in the history of touch interfaces, you might want to check out Bill Buxton’s Multi-Touch Systems that I Have Known and Loved.

Pointer Events vs. Touch Events

As mentioned above, generic pointer events such as the original W3C idea or MSPointer, have the benefit of supporting multiple pointer devices. In fact, with a Samsung tablet running Windows 8, mouse, pen, and fingers are all normalized to MSPointer; you can even use the pointerType property to determine which type of pointer is being used. In addition to supporting all current pointer devices, MSPointer is designed in such a way that future devices can easily be added, and existing code will automatically support the new device. Even better, MSPointer event objects have the same structure as other events, reducing the learning curve compared to the conglomerate of TouchEvent, TouchList, and Touch.

Another big difference between MSPointer and Touch is that MSPointer has support for hovering (over and out events). While most touch devices have a hardware limitation that doesn’t allow for hovering, Sony recently announced the Xperia sola with “magical floating touch technology.” This brings up an important issue: Touch Events were designed based on a specific device for a specific type of input. Pointer Events represent a completely different approach to input on the Web. While we’ve already covered how this impacts developers, it’s interesting to consider the impact on hardware manufacturers. In order for Apple to succeed with touch interfaces, they had to create a new event model. Innovation for new form factors and new input methods will either be stifled by the existing standards or will require a new set of APIs, following in Apple’s footsteps with the iPhone and Touch Events. Pointer Events provides a clean solution not only for developers, but for hardware manufacturers as well. It’s conceivable that in a few years developers could use Pointer Events as the only event model for pointers, leaving Mouse Events as a thing of the past.

A Splintered Future

Although the W3C is still planning to move forward with the Touch Events spec (pending a recommendation from the PAG), the future is unclear. Even if the PAG determines that Apple’s patents don’t apply and the spec becomes a W3C Recommendation, it’s not clear that Microsoft would implement such a model given the need for a multi-input event system in Windows. If the W3C were to change directions and start a Pointer Events spec, it’s not clear that Apple, or more broadly WebKit, would implement the new event model. It’s entirely possible that even with a W3C Recommendation, we’ll be stuck for years without a consistent event model across browsers and devices.

Regardless of which model the W3C chooses to pursue, jQuery is dedicated to filling in the gaps, just like we do for other events such as submit and change. We think the pointer event model is easier to use and more future-proof, and we hope that it can be standardized, even if Touch Events are standardized as well. However, we are only interested in normalizing to a W3C Recommendation, and will not provide custom pointer events if there is no official W3C specification. We’re working with the W3C and Microsoft to try to find the best way forward for our users and the Open Web.

Call to Action: Microsoft to Submit Pointer Event Proposal

We would like to publicly call upon Microsoft to submit a proposal to the W3C for Pointer Events. The Touch Events Working Group, and by extension various browser vendors, have stated interest in pointer events. The most effective way to proceed would be for Microsoft to officially submit a proposal to the W3C.

Call to Action: Community to Experiment with Both Event Models

We would also encourage the community to experiment with Touch and MSPointer. Play with the APIs, build apps, and provide feedback. If you’re interested in this, but don’t have the necessary hardware, consider pairing up with one or more local developers who do. While there are a lot of developers building on top of Touch, there are very few people building on top of MSPointer, and even fewer publicly comparing them. We encourage you to send your feedback directly to the W3C public-webevents mailing list, but feel free to leave feedback here and we will pass it along.

Call to Action: Submit Prior Art

If you know of any prior art for multi-touch/touch lists, even outside of the Web, please get in touch with the W3C. This includes programming models and APIs, especially those using events. This will help the Patent Advisory Group come to a conclusion sooner. Again, if you’d rather leave comments here, we will pass them along.

Bowling for jQuery – April 2012, Washington, D.C.

Posted on by

The jQuery team is going bowling and we’d love to have you join us! We’ll be spending the evening of Friday, April 13th at King Pinz in Leesburg, VA, a bit outside of Washington, DC. We’ll have a private room with 6 lanes from 6 to 10 PM. The night will feature unlimited bowling, dinner, desserts, drinks, and billiards. There’s even a cigar bar, if you’re into that!

King Pinz

Very limited space – get your ticket fast.

Bowling

  • Private room with 6 lanes
  • Unlimited bowling (shoe rental included) for 4 hours
  • Cozy couches with cocktail tables
  • King Pinz: Photos
  • Private Room: 360 degree tour

Dinner

  • Appetizers, entrees, and desserts
  • All night

Drinks

  • Open bar
  • All night

Billiards

  • Private billiards table and lounge area

Cigar Bar

Prizes

  • 1 winner gets a copy of Adobe Creative Suite Master Collection 5.5 (a $2,600 value)
    Adobe Creative Suite Master Collection 5.5
    Thanks Adobe.
  • There will be other prizes as well. Cool prizes. Must be present to win.

Who will be there?

  • Dave Methvin
  • Yehuda Katz
  • Leah Silber
  • Rick Waldron
  • Karl Swedberg
  • Adam J. Sontag
  • Scott González
  • Dan Heberden
  • Richard D. Worth
  • Corey Frang
  • Kris Borchers
  • You?

Sponsors

Please join us in thanking our thouroughly awesome sponsors for this event:

 

CustomInk Design T-shirts Online

 

Bocoup - Open Web Technology by and for programmers

 

Adobe

 

Fluidhire - Innovative Technology and New Media Recruiting

 

MoDevUX

 

We know you love jQuery and we love you for showing it.

jQuery 1.7.2 Released

Posted on by

jQuery 1.7.2 is looking good! The release candidate went smoothly so we’ve made only one small change and are releasing it to your eager hands today. You can get the oven-fresh code from the jQuery CDN now, with Google and Microsoft CDNs soon to follow:

Note: If you’re using jQuery Mobile, please use jQuery 1.7.2 only with jQuery Mobile 1.1. For previous versions of jQuery Mobile, stay with jQuery core 1.7.1 or earlier.

You can use the bug tracker to report bugs; be sure to create a test case on jsFiddle so we can figure it out easily. If you’re not sure it’s a bug, ask on our forum or on StackOverflow. Please don’t use the blog comments below to report bugs.

As always, this release wouldn’t have been possible without the hard work of many people. First, the jQuery Core Team: gnarf, jaubourg, mikesherov, rwldrn, and timmywil. The support of the jQuery UI, Mobile, and Infrastructure teams was greatly appreciated as well, especially danheberden’s valiant struggle against Trac.

Community members like adebree, caii, cmc3cn, KYSergey, mathiasbynens, miskith, MrMamen, Orkel, pasky, SineSwiper, tavelli, and vlazar pitched in by reporting, verifying, and fixing bugs. Special jQuery Gold Leaf Cluster thanks to gibson042 and sindresorhus for their work in making 1.7.2 a great release. Don’t let these people have all the fun! If you’d like to contribute to the web’s most popular Javascript library, hop onto #jquery-dev on IRC or the Developing jQuery Core section on our forum and say hello!

Many thanks to Louis-Rémi Babé, who submitted a patch to fix a regression with negative margin animations a mere 30 minutes before the release!

jQuery 1.7.2 Change Log

Here’s the change log of the 1.7.2 release.

Ajax

  • #4624: Charset in default ajaxSettings.contentType
  • #10978: jQuery.param() should allow non-native constructed objects as property values
  • #11264: evalScript() uses defaults set by ajaxSetup()
  • #11426: jQuery.ajax() always fails when requesting JPG images in IE

Attributes

  • #5571: Allow chaining when passing undefined to any setter in jQuery
  • #10828: attr(“coords”) returns undefined in IE7
  • #10870: Incorrect behaviour of $.removeAttr(“selected”)
  • #11316: Consider looking through valHooks by element type first, then by nodeName instead of the other way around

Build

  • #10692: Configure the jshint options to more accurately match the style guide
  • #10693: generalize the “test something in an iframe” code in unit tests
  • #10901: have unit tests fail if the tester is running from file:// or doesn’t have PHP
  • #10902: ability to test a built version of jQuery in unit tests
  • #10931: Unit tests shouldn’t require internet access

Core

  • #10466: jQuery.param() mistakes wrapped primitives for deep objects

Css

  • #10639: outerWidth(true) and css(‘margin’) returning % instead of px in Webkit
  • #10754: have jQuery.swap return the return of the callback instead of just executing it
  • #10782: Incorrect calculating width
  • #10796: Bug in IE7 with $(‘#el’).css.(‘background-position’)
  • #10858: css.js regular expressions are incomplete
  • #11119: The curCSS function only need 2 arguments

Data

  • #11309: hexadecimal-formatted data-* attributes parsed incorrectly

Deferred

  • #11306: calling .disable() or .lock() on a $.Callbacks object breaks its fired() status

Dimensions

  • #3838: $(document).height() incorrect in IE6

Effects

  • #8498: Animate Hooks
  • #10006: method show is not working as expected in all browsers when called for document fragment
  • #10848: Animation toggling loses state tracking in certain atomic edge cases
  • #11415: Silently ignore negative CSS values where they are illegal
  • #11469: Negative margin in animations (.animate)

Event

  • #8165: .live(‘click’, handler) fires on disabled buttons with child elements in Chrome
  • #10819: Eliminate “this.on.call(this, “
  • #10878: $(“select”).live(“change”, function(){ …broken in IE8 in jQuery 1.7
  • #10961: Error in XRegExp using jQuery 1.7.1 in IE6-9
  • #10970: The .on() selector parameter doesn’t work with :not(:first) selector
  • #10984: Cannot off() custom events ($.event.special)
  • #11021: Hover hack mangles a namespace named “hover”
  • #11076: .clone(true) loses delegation filters
  • #11130: jQuery.fn.on: binding map with null selector ignores data
  • #11145: $(document).on() not working with name=”disabled”

Manipulation

  • #9427: Passing undefined to .text() does not trigger setter
  • #10753: inline the evalScript function in manipulation.js as it’s only used once
  • #10864: text() method on a document fragment always returns the empty string
  • #11055: Update HTML5 Shim elements list to support latest html5shiv
  • #11217: Append problem with webkit
  • #11291: Cloning XMLDoc’s with HTML5 nodeName’s breaks on IE
  • #11323: script tags with type=”text/ecmascript” leak into the DOM
  • #11356: safeFragment memory leak

Misc

  • #10952: .fired() doesn’t work on Callbacks object when it is flagged with “once”
  • #11257: Wrong path to source files in test suite if PHP missing

Queue

  • #10967: .promise() does not attach methods onto target

Support

  • #7986: Bug in $.support.boxModel if page has DIV-element CSS
  • #11048: Support Tests affect layout for positioned elements in IE6-9
  • #11337: Bug in $.support.reliableMarginRight

Traversing

  • #11370: $(‘<div>’).siblings() throws exception

Announcing the 2012 San Francisco jQuery Conference!

Posted on by

It’s that time of year again…time to talk about the next jQuery Conference!

Mark your calendars for June 28th and 29th. By popular demand, the next jQuery Conference will be in San Francisco proper (as opposed to Mountain View), at the fantastic UCSF Mission Bay Conference Center. If you haven’t been to an event there before, some highlights:

  • Pretty much the best conference wifi we’ve ever worked with
  • Pretty much the best conference food we’ve ever eaten
  • Free flowing coffee, sodas and drinks all day long
  • Great space, with comfy seating, great AV, parking, easy access to public transit, space for partying, and so on and so on and so on

We’re incredibly excited about the new space, and about the way the 2012 SF show is shaping up! We’re going slightly smaller and single track this year too, so things are a bit simplified, a lot more intimate, and there’s less general shuffling about. Registration is open now, and space is extremely limitedTickets have sold out pretty quickly in the past, and there are about 150 tickets less than last time!

Call for Proposals

We’ve opened a call for speaking proposals, which will remain open until May 13th. We encourage any and all to apply. In fact, we’re borrowing a page from JSConf’s playbook this year and doing an “inverted” call:  you’re encouraged to nominate your dream speaker (or anyone else) for a speaking slot on the subject of your choice. Of course, you’re welcome to nominate yourself!  We love to spice it up with new speakers, new topics, and pretty much whatever you can think of. Submit a proposal now!

Sponsors

Conferences are expensive. So is running an open source project. We couldn’t do any of it without your help and support… so listen up! If you work for a company that’s hiring, a company that wants some developer publicity, or a company looking to help out and give back to the community, send them our way. Take a look at the conference prospectus if you (or your bosses) are feeling generous :) Sponsorship benefits and mega karma points are both up for grabs…

Training

We’re still on the lookout for a space for training in SF on Wednesday, June 27th. If your company has a space, or you have an idea for a venue, please shoot us an email, and we’ll be eternally grateful.

That’s it for today, folks. Keep an eye out for upcoming announcements about speakers, sponsors, training days and all varieties of miscellany. We’ll also be updating the conference site with things like venue details and after parties, so keep an eye on that one too. Lastly, as always, if you’ve got questions or comments, reach out or leave a note here.