Don't miss new standard javascript APIs

Don't miss new standard javascript APIs

The new javascript (1.6) provides many useful features, specially in DOM manipulation, but I noticed that jQuery uses really few of them.
For example, the feature element.classList could be used in add/remove/toggle/hasClass like this:
  1. // When in 'use strict' mode, the first argument of call function cannot be null or undefined
  2. // so make it an empty string
  3. if (Object.prototype.toString.call(document.documentElement.classList || '') === '[object DOMTokenList]') {
  4.     var methods = {
  5.         addClass: 'add',
  6.         removeClass: 'remove',
  7.         toggleClass: 'toggle', 
  8.         hasClass: 'contains'
  9.     };
  10.     for (var name in methods) {
  11.         jQuery.fn[name] = function(method) {
  12.             return function(className) {
  13.                 return this.each(function() {
  14.                     this.classList[method](className);
  15.                 });
  16.             }
  17.         }(methods[name]);
  18.     }
  19. }
  20. else {
  21.     // current implementation of jQuery
  22. }
Yes I ormit many logic in those function like we can call addClass('a b c') with space-separated class list, but the core logic is there to utilize new feature in javascript 1.6 and surelly much quicker than the normal implementation.
In my Firefox 4.0 b11, when I run the code below for 100,000 times, my code is about 1 time faster than the normal jQuery one:
  1. var div = $('<div class="a b c d e f g"></div>').addClass('a b c d e f g');
  2. console.time('toggleClass');
  3. for (var i = 0; i < 100000; i++) {
  4.     div.toggleClass('abc');
  5. }
  6. console.timeEnd('toggleClass');
  7. // jQuery: 1624ms
  8. // after replace jQuery's implementation: 862ms

Also, there are other new features such as Array.forEach / Object.keys can be utilized in jQuery

sorry for poor english
thanks